Top "Query-optimization" questions

For questions about making database queries run faster.

T-SQL Where Clause Case Statement Optimization (optional parameters to StoredProc)

I've been battling this one for a while now. I have a stored proc that takes in 3 parameters that are …

sql-server tsql query-optimization case where-clause
How can I analyse a Sqlite query execution?

I have a Sqlite database which I want to check the indexes are correct. MS SQL Analyser is great at …

sql sqlite query-optimization sql-execution-plan
Improving performance of Sql Delete

We have a query to remove some rows from the table based on an id field (primary key). It is …

sql database sybase query-optimization database-optimization
mysql, ifnull vs coalesce, which is faster?

if it's known that there are only two values to candidate for the result of a column, ifnull(a, b) …

mysql query-optimization
Oracle - Understanding the no_index hint

I'm trying to understand how no_index actually speeds up a query and haven't been able to find documentation online …

oracle query-optimization hint
Optimize Postgres timestamp query range

I have the following table and indices defined: CREATE TABLE ticket ( wid bigint NOT NULL DEFAULT nextval('tickets_id_seq'::…

postgresql indexing query-optimization database-partitioning postgresql-performance
Handling optional/empty data in MongoDB

I remember reading somewhere that the mongo engine was more confortable when the entire structure of a document was already …

mongodb optimization query-optimization nosql
Mysql Explain Query with type "ALL" when an index is used

I ran a query in Mysql like below: EXPLAIN SELECT * FROM( SELECT * # Select Number 2 FROM post WHERE parentid = 13 ORDER BY …

mysql sql indexing query-optimization explain
Why does this sql query do a key lookup?

I have a table User with a bunch of indexes. One of them is a unique index on the AccountIdentifier …

sql sql-server query-optimization sql-execution-plan
OR Operator Short-circuit in SQL Server

I want to consult SQL Server OR short-circuit Code: DECLARE @tempTable table ( id int ) INSERT @tempTable(id) values(1) DECLARE @id …

sql-server tsql query-optimization short-circuiting