New Webinar: Modernising Without Destabilising: How Bread Financial Is Building Confidence Through Change

Learn more

New webinar with Bread Financial

Learn more
Contact us

Blogs

Bad Code = Bad Performance Part 3

<span id="hs_cos_wrapper_name" class="hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text" style="" data-hs-cos-general-type="meta_field" data-hs-cos-type="text" >Bad Code = Bad Performance Part 3</span>

Date 29 June 2026

Author Team Capacitas

Part 3 – Database Queries

This is part three of the blog discussing how bad code does often lead to bad performance of web pages, and what bad coding habits can contribute to the slow performance. In the previous parts, I’ve discussed how a lack of parallelism in code and over-reliance on server-side code can slow performance down.

In this part of the blog, I shall be looking at how poorly structured and unnecessarily expensive database queries can contribute to bad performance.

Poorly structured and expensive database queries

If many database queries are being made by the server-side code and executed on the database server, there are many connections being made between server-side and database-side. So, it is important to make sure that database queries are written in a manner that optimises performance as much as possible.

Discover how the Senior Delivery Manager at easyJet reduced risk through  capacity management in our on-demand webinar

 

If queries are returning more columns and rows than what are actually needed, performance is being wasted on fetching back data that actually isn’t required. So, querying just the columns and rows of interest will aid with speeding up the performance of a web page.

bad code part 3 code

A query may be doing too many joins or lookups to other database tables, or more than what is required. There may even be too many SqlConnection instances active and open, which all use up resource and performance to execute database queries from C#. Managing the queries and connections can help limit the impact database queries will have on performance.

bad code part 3 code sql

The Microsoft Developer site lists these and several more performance issues caused by database queries. Check out the link here. A lot of the points raised by both myself and Microsoft may seem like common sense, but these are points which are often overlooked when developing database queries for web pages.

Stay tuned for the final part of this blog, where I shall discuss how use of variables can have a big impact on web page performance.

 

Webinar easyJet reduce risk through capacity management

Team Capacitas
About the author

Team Capacitas

Capacitas is a cloud and AI value partner. We translate rapid technological change into enduring commercial advantage by converting every unit of compute into enterprise value.

FinOps and AI: Building the Financial Discipline for the Next Wave of Enterprise Intelligence

AI FinOps represents an evolution rather than a replacement of traditional FinOps. It extends the model into a domain where financial, technical, and product decisions are tightly interconnected.

Read insight

Confidence Under Load: How We Verified AKS Readiness for Peak

How Capacitas verified AKS readiness for peak demand by validating workload performance, autoscaling, cluster capacity, monitoring, and incident response.

Read insight

Building Cloud Resilience: Lessons from the AWS Outage

Learning from the Latest Outage. Events like this week’s AWS disruption highlight one clear truth: resilience must be designed, not assumed.

Read insight

Bringing Order to Chaos: A Practical Guide to Chaos Testing in the Cloud

In today’s cloud-native environments, resilience is not optional—it’s critical. Chaos testing has emerged as a key practice for validating system behaviour under failure conditions.

Read insight