SShortSingh.
Back to feed

How Database Indexes Work and Why Your Queries Fail at Scale

0
·1 views

Queries that run smoothly in development often break down in production when table sizes grow from thousands to millions of rows, typically due to full table scans. Database indexes, most commonly implemented as B-trees, allow the query engine to locate matching rows in roughly 20 comparisons instead of scanning millions, cutting query time from seconds to milliseconds. However, indexes are not free — each one added to a table increases the cost of write operations like INSERT, UPDATE, and DELETE. A key concept called selectivity determines whether the query planner will even choose to use an index, based on the fraction of rows a filter is expected to return. Developers can use EXPLAIN plans to inspect query execution and catch performance bottlenecks before slow queries reach production.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Cheap AI Models Now Cost 90% Less, Reshaping Economics of AI Development

A new generation of small, efficient AI models has sharply cut the cost of running AI workloads, with models like GPT-5.6 Luna priced at just $0.20 per million input tokens — an 80% reduction from its predecessor. The cost drop is largely driven by Mixture-of-Experts (MoE) architecture, which activates only a fraction of total parameters during inference, delivering near-frontier quality at a fraction of the compute cost. Models from OpenAI, Alibaba, Zhipu AI, and DeepSeek all now ship at or below $1.20 per million output tokens, compared to $10 or more for top-tier models. The capability gap between cheap and premium models has narrowed significantly, with one production user reporting GPT-5.6 Luna achieved six times lower cost with only marginal quality loss on a cybersecurity benchmark. For developers, the practical implication is that AI-powered applications previously unviable on cost grounds — such as personalized content generation — may now be economically sustainable.

0
ProgrammingDEV Community ·

How to Properly Handle Claude API Refusals in Structured Output Parsing

When using Anthropic's Claude API, an HTTP 200 response does not guarantee the returned content contains valid, schema-compliant JSON. Claude can return a stop_reason of 'refusal' or halt early due to max_tokens, both of which can break applications that immediately attempt to deserialize response text. Developers are advised to inspect the response envelope and classify the stop_reason before attempting any JSON deserialization. The current stable API uses output_config.format for JSON schema definitions, replacing an older beta format that no longer requires a special request header. Modeling the decoding process as a result type rather than an exception-driven flow helps applications handle all documented response states deliberately and safely.

0
ProgrammingDEV Community ·

Swift Stock App Brings Mobile Barcode Scanning and Inventory Control to Shopify

A mobile app called Swift Stock allows warehouse teams to conduct cycle counts across multiple Shopify locations by scanning barcodes or SKUs directly from their phones. Each scan updates inventory quantities and confirms bin locations in real time, eliminating the need for spreadsheet handoffs. The app also supports order picking verification, marking fulfillments complete only when every scanned item matches the order. Stock transfers between Shopify locations and external destinations can be managed from the same mobile interface, with a unified history log and one-click revert option for errors. The developer notes that Swift Stock does not cover purchase orders or demand forecasting, functions currently handled by Shopify Stocky ahead of its retirement on August 31, 2026.

0
ProgrammingDEV Community ·

AI Planning Agent Flagged 96 of 97 High-Stakes Goals — and That Was Intentional

A developer building an AI planning agent called PlannerCritic found that 96 out of 97 strict goals were escalated rather than approved during field testing. Initially appearing to be a failure, the high refusal rate was later reframed as a sign of correct behavior in a high-stakes planning system. The developer argues that a plausible but flawed plan is more dangerous than a clean refusal, since hidden assumptions in generated plans can mislead human reviewers before errors are caught. PlannerCritic was designed to produce only three terminal states — approved, escalated, or blocked — rather than maximizing plan output. The experience prompted a reassessment of how AI planning agents should be evaluated, shifting focus from approval rates to the quality and honesty of refusals.

How Database Indexes Work and Why Your Queries Fail at Scale · ShortSingh