Top "Query-optimization" questions

For questions about making database queries run faster.

How to estimate SQL query timing?

I'm trying to get an rough (order-of-magnitude) estimate of how long time the following query could take: mysql> EXPLAIN …

mysql query-optimization timing estimation time-estimation
MySQL "IN" queries terribly slow with subquery but fast with explicit values

I have a MySQL query (Ubu 10.04,Innodb, Core i7, 16Gb RAM, SSD drives, MySQL params optimized): SELECT COUNT(DISTINCT subscriberid) …

mysql query-optimization
For autoincrement fields: MAX(ID) vs TOP 1 ID ORDER BY ID DESC

I want to find the highest AutoIncremented value from a field. (its not being fetched after an insert where I …

sql sql-server sql-server-2005 query-optimization
Improving OFFSET performance in PostgreSQL

I have a table I'm doing an ORDER BY on before a LIMIT and OFFSET in order to paginate. Adding …

database postgresql query-optimization
How to Improve Query Performance with many JOINs

I have a query (with the purpose of making a view) which is using a few joins to get each …

mysql sql performance select query-optimization
mysql fix Using where;

My SQL Query: SELECT * FROM updates_cats WHERE uid =118697835834 ORDER BY created_date ASC Current Indexes: index1(uid, created_date) …

mysql sql indexing query-optimization where
Selecting COUNT from different criteria on a table

I have a table named 'jobs'. For a particular user a job can be active, archived, overdue, pending, or closed. …

sql query-optimization subquery
SQL Wildcard Search - Efficiency?

There has been a debate at work recently at the most efficient way to search a MS SQL database using …

sql sql-server sql-server-2008 query-optimization processing-efficiency
Meaning of "Select tables optimized away" in MySQL Explain plan

What is the meaning of Select tables optimized away in MySQL Explain plan? explain select count(comment_count) from wp_…

sql mysql performance query-optimization sql-execution-plan
How to optimise MySQL queries based on EXPLAIN plan

Looking at a query's EXPLAIN plan, how does one determine where optimisations can best be made? I appreciate that one …

mysql query-optimization