Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose an index for a real, recurring query—not simply because a column appears in its WHERE clause. Start with the query’s filters, joins, sort or grouping, and output columns; then test a narrow candidate index and keep it only if execution plans and representative workload measurements show a benefit. The examples below are candidates, not guarantees: data distribution, query frequency, and write costs can change which design is best.

How do you choose the right index for a SQL query?

Begin with the query and workload, not a list of columns. An index can help the database find matching rows, join tables, provide rows in useful order, or retrieve a query’s output from the index itself. Those benefits depend on how the query is written and how much of the table it needs. SQL Server’s index design guide and MySQL’s index documentation both frame index design around workload and query behavior.

  1. Pick an expensive query from the real workload. Record how often it runs and how important its response time is. An occasional query may not justify extra write and storage costs.
  2. Map its shape. Note the predicates, join conditions, ORDER BY or GROUP BY, and columns returned. Also consider how many rows the query is expected to read.
  3. Check whether predicates can use an index. Compare compatible types and avoid applying functions or transformations to indexed columns when that prevents a direct search. MySQL notes that conversions or incompatible types or character sets can prevent index use in some comparisons.
  4. Check existing indexes. Look for an index that already supports the same leading columns or overlaps the proposed design before adding another.
  5. Test one focused candidate at a time. Inspect the plan and measure representative reads and writes. Keep, revise, or remove the candidate based on workload results, not on the index’s existence or a plan label alone.

For example, consider orders(order_id, customer_id, status, created_at, total_amount). A recurring query with WHERE customer_id = ? ORDER BY created_at DESC is a reason to test a composite key beginning with customer_id and followed by created_at. The syntax and whether descending order changes the plan are engine- and version-dependent; only measurement on the target database can establish whether it helps.

What order should columns be in a composite index?

A composite index stores keys in an order, so the first column is not interchangeable with the second. MySQL documents the leftmost-prefix rule: an index on (a, b, c) can support lookups using (a), (a, b), or (a, b, c), but it does not provide the same lookup for (b) alone. SQL Server’s design guide makes the same practical point with its example that an index beginning with LastName does not help a query searching only by FirstName. PostgreSQL has its own multicolumn planning behavior, so consult its multicolumn index documentation and inspect plans for the version and query in use.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

A useful starting hypothesis for many queries is to put recurring equality conditions in a useful leading prefix, then consider a range or ordering column. It is a hypothesis, not a universal ordering formula: selectivity, data distribution, joins, range conditions, sort direction, and other queries using the same index can favor a different key order. MySQL’s multiple-column index guide explains its prefix behavior; SQL Server guidance likewise considers predicates, joins, and key order.

Equality plus ordering

For SELECT order_id, created_at FROM orders WHERE customer_id = ? ORDER BY created_at DESC, test (customer_id, created_at) as a candidate. It places the equality condition first and the sort column after it, but does not establish that the optimizer will choose it or that it will be faster.

Equality plus a date range

For WHERE status = ? AND created_at >= ?, test a key such as (status, created_at) if that pattern recurs. Compare alternatives using actual data distribution and plans; a low-selectivity status value or other workload patterns may alter the trade-off.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Joins and multiple queries

Include join columns in the design when the query workload warrants it, and evaluate the full query rather than indexing each predicate independently. If several queries use different leading columns, one composite index may not serve them all. Separate single-column indexes are not automatically equivalent to a composite index that matches a recurring filter-and-order pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should you index every column in a WHERE clause?

No. A column’s presence in a predicate does not show that an index is useful. The optimizer weighs the expected rows, table size, data distribution, the cost of accessing the index and then table rows, and whether a scan is cheaper. MySQL explicitly notes that reading sequentially can be faster when a query needs most rows or a table is small. Indexes also consume storage and require maintenance when indexed values change; unnecessary indexes can add write work and optimizer overhead.

  • Prioritize predicates and joins in frequent, expensive queries rather than indexing every mentioned column.
  • Check whether an existing index already provides a useful prefix or overlapping coverage.
  • Account for inserts, updates, and deletes as well as reads; changing an indexed value requires index maintenance.
  • Retain only indexes with an observed workload benefit that justifies their storage and modification costs.

Separate single-column indexes can sometimes be combined by an optimizer, but that is not a reason to assume they match a suitable composite key. Compare candidate designs against actual plans and representative workload behavior.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

When should you use a covering index?

A covering index contains the information a query needs to search, order, and return its result, potentially reducing access to the base table. The trade-off is a wider index: additional key or payload columns consume space and increase maintenance work. Add output columns only when coverage is likely to matter and the index remains acceptably narrow. Microsoft specifically advises against adding too many columns to a covering index because doing so can inflate storage, I/O, and memory use.

Engine Covering mechanism Practical qualification
SQL Server A nonclustered index can use INCLUDE for nonkey output columns. Use key columns for searching, joining, aggregation, or ordering as appropriate; reserve included columns for payload needed only in output. See Microsoft’s index design guide.
MySQL A covering index can supply all columns required by a query from the index tree. MySQL does not use SQL Server’s same INCLUDE syntax; requested columns must be available from the index. See How MySQL Uses Indexes.
PostgreSQL Index-only scans are possible, and supported index types can store payload columns with INCLUDE. Having all requested columns in the index does not guarantee that heap reads are avoided; visibility-map state affects whether an index-only scan can avoid them. See PostgreSQL’s index-only scan documentation.

For instance, if a query filters by customer_id and returns only created_at and total_amount, those output columns might be candidates for coverage after testing the key. In SQL Server or supported PostgreSQL index types, they may be payload columns with INCLUDE; in MySQL, an index must make the required columns available through its indexed columns. Do not widen an index for coverage unless the measured read benefit offsets its costs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When are filtered or partial indexes useful?

A recurring query that targets a well-defined subset can sometimes use an index that contains only that subset. This is an engine-specific feature, not portable syntax. SQL Server supports filtered indexes, while PostgreSQL supports partial indexes. For PostgreSQL, the planner must be able to establish that the query predicate implies the partial-index predicate.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

For example, a workload repeatedly retrieving active orders may justify testing a SQL Server filtered index or PostgreSQL partial index whose predicate corresponds to the query’s active-row condition. Ensure the query condition and index predicate are compatible, then confirm plan use. The relevant references are Microsoft’s SQL Server index design guide and PostgreSQL’s partial index documentation. Do not copy either engine’s syntax into MySQL as though it had the same general partial-index feature.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why is the database not using the index?

An index can be valid and still not be the least-cost choice for a particular query. A scan may be cheaper for a small table or when many rows are needed. Other possibilities include a predicate that does not align with the index’s leading columns, a transformation or type conversion that blocks direct use, or estimates that reflect the table’s distribution poorly. Diagnose the specific query and plan rather than assuming the optimizer is wrong.

Inspect the plan

  • SQL Server: inspect estimated or actual execution plans. Use Query Store and index usage information as additional evidence about workload behavior, as described in Microsoft’s design guide. A seek is not, by itself, proof of a faster query; compare observed behavior.
  • MySQL: run EXPLAIN for the query and review the chosen key and plan details. The MySQL index documentation describes index uses and their limits.
  • PostgreSQL: use EXPLAIN to inspect the plan. For runtime and buffer evidence, EXPLAIN (ANALYZE, BUFFERS) executes the statement as well as reporting its plan; take care with statements that change data or have side effects. Consult PostgreSQL’s Using EXPLAIN documentation.

Check the index-query match

For a composite index, compare the query’s conditions with its leading key columns. Verify that the query does not transform the indexed value in a way that prevents direct searching, and check that compared values have compatible types and character sets where relevant. Then examine estimated versus observed row counts and test with representative data and parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

How should you validate and maintain an index design?

  1. Capture a baseline. Record a representative execution plan and query behavior before changing indexes, including the workload context in which the query runs.
  2. Make one focused change. Add or alter a candidate index where operational constraints permit, rather than changing several designs at once.
  3. Test representative reads and writes. Confirm whether the target query improves and whether write-heavy operations, storage, or other queries are adversely affected.
  4. Review overlap and usage. Check whether the new index duplicates an existing one or adds little value across the workload. SQL Server’s Query Store and index usage views can help assess use; all engines still require workload-aware interpretation.
  5. Keep, revise, or remove it. Base the decision on observed overall benefit, not simply on whether a plan names the index.

Unique indexes belong where uniqueness is a real data constraint, not merely as a performance guess. Other specialized index types may suit particular data or operators, but for ordinary B-tree query patterns the starting point is the query-shaped candidate and measured plan.

What differs across SQL Server, MySQL, and PostgreSQL?

Design question SQL Server MySQL PostgreSQL
Composite key order Leading key matters; design around predicates and joins. See the SQL Server guide. Lookups use leftmost prefixes of composite indexes; later columns alone do not provide the same prefix lookup. See Multiple-Column Indexes. Use PostgreSQL’s multicolumn rules for the target version and verify with EXPLAIN; do not assume another engine’s syntax or planning behavior. See Multicolumn Indexes.
Coverage Nonkey payload columns can be added with INCLUDE. Coverage comes from required columns being available in the index; do not assume SQL Server’s INCLUDE syntax. Index-only scans and INCLUDE are available for supported index types, but heap avoidance depends on visibility information.
Subset index Filtered indexes are supported. No general equivalent is established here; do not assume SQL Server or PostgreSQL partial-index syntax applies. Partial indexes are supported when the query predicate can be shown to imply the index predicate.
Plan verification Estimated and actual execution plans; Query Store and usage information can add workload context. EXPLAIN shows the chosen key and plan details. EXPLAIN inspects the selected plan; runtime measurements provide additional evidence.
Costs Indexes consume storage and add I/O and update work. Indexes consume space and require maintenance for inserts, updates, and deletes; scans can be preferable when most rows are read. Account for storage and modification costs, and validate PostgreSQL-specific plan behavior.

The documentation references here were checked on 2026-10-04 UTC: the SQL Server guide was viewed at its SQL Server 17 URL, the MySQL Reference Manual pages are for 26.7, and PostgreSQL’s current documentation resolved to PostgreSQL 18. These identify the documentation versions observed, not the version running on your server. Match guidance to your installed release and test on that system. PostgreSQL’s broader index chapter covers index types and related topics.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.