Skip to Main Content
Sustainable Web Design Logo
  • Home
  • Guidelines
  • Emissions
  • Ratings
  • Contact

◂ Web Development guidelines

3.24 Run Fewer, Simpler Queries As Possible

Web Development

Making multiple requests whether HTTP or within a database has a carbon cost as infrastructure has to send that information back and forth. As such, managing how you store and use data locally for a visitor will help reduce wasted cycles.

Criteria

  • Database Queries: If you need information that is stored in a database, and you require it (or it’s likely to be requested) more than once in your code, access the database only once, and store the data locally for subsequent processing. Also, avoid reliance on framework helpers that might defer filtering to later on in the process.

Impact

Medium

Effort

Low

Benefits

  • Environmental:
    Filtering out unneeded data at a deeper level of the application may reduce energy usage, as less processing is required for (de)serialization.
  • Performance:
    By holding the data locally rather than remotely, you can avoid waiting for an additional HTTP request to occur to process the string. Relational databases and other specialist data stores are generally heavily optimized for data filtering and retrieval. Performing transformations at this level of the application may lead to reduced CPU time and faster responses.
  • Economic:
    Rather than pushing multiple additional demands to the server (which could lead to stress failures and lost business), an optimized codebase can reduce bandwidth overheads.

GRI

  • materials: Low
  • energy: Low
  • water: Low
  • emissions: Low

Example

  • Code:
    $value = get_post_meta( int $post_id, string $key = '', bool $single = false ): mixed
  • get_post_meta Function.

Resources

  • [GPFEDS] 4.9 – UX and UI (Server Requests) (PDF)
  • [GPFEDS] 7.3 – Back-End (Background Processing) (PDF)
  • [GPFEDS] 6.5 – Front-End (Upload Triggers) (PDF)
  • High Performance MySQL: Query Performance Optimization
  • Improving PHP Performance for Web Applications
  • Minimizing SQL query response times
  • Performance Tuning SQL Queries
  • Query optimization techniques in SQL Server
  • SQL Query Optimization

View the Guideline

Tags

PerformanceNetworking

Share

More web development guidelines

3.1 Identify Relevant Technical Indicators

Web Development

3.2 Minify Your HTML, CSS, and JavaScript

Web Development

3.3 Use Code-Splitting Within Projects

Web Development

Learn about W3C’s Sustainable Web Interest Group:

A global community advancing sustainability on the web.

Explore the group

This site is brought to you by

Mightybytes Wholegrain Digital
Website Carbon

This page loaded in 0.25 seconds and emitted just 0.5g of CO2

Visit Website Carbon
Ecograder

How green is your website?

Visit Ecograder
© Copyright Sustainable Web Design 2025. Privacy Policy.