What does “Recheck Cond” in Explain result mean?

This was explained by Tom Lane on the mailing list: what is “Recheck condition” and why is it needed? If the bitmap gets too large we convert it to “lossy” style, in which we only remember which pages contain matching tuples instead of remembering each tuple individually. When that happens, the table-visiting phase has to … Read more

How to improve performance on a clustered index seek

I’m generalizing here, but… A clustered index seek is, for the most part, the best-case scenario. The only ways I can think of to improve performance would be: Update the query to return fewer rows/columns, if possible; Defragment or rebuild the index; Partition the index across multiple disks/servers. If it’s only returning 138 rows, and … Read more

Easy way to run “explain” on query sets in django

Well, there seems to be nothing out there except a toolbar so I wrote my own mixin to give me an explain() method on my querysets: from django.db import connections from django.db.models.query import QuerySet class QuerySetExplainMixin: def explain(self): cursor = connections[self.db].cursor() cursor.execute(‘explain %s’ % str(self.query)) return cursor.fetchall() QuerySet.__bases__ += (QuerySetExplainMixin,) Hopefully this is useful to … Read more

What “Clustered Index Scan (Clustered)” means on SQL Server execution plan?

I would appreciate any explanations to “Clustered Index Scan (Clustered)” I will try to put in the easiest manner, for better understanding you need to understand both index seek and scan. SO lets build the table use tempdb GO create table scanseek (id int , name varchar(50) default (‘some random names’) ) create clustered index … Read more

Meaning of “Select tables optimized away” in MySQL Explain plan

From the MySQL documentation: The query contained only aggregate functions (MIN(), MAX()) that were all resolved using an index, or COUNT(*) for MyISAM, and no GROUP BY clause. The optimizer determined that only one row should be returned. Basically this means your query uses data that is directly available to MySQL and the query will … Read more

Measuring Query Performance : “Execution Plan Query Cost” vs “Time Taken”

The profiler trace puts it into perspective. Query A: 1.3 secs CPU, 1.4 secs duration Query B: 2.3 secs CPU, 1.2 secs duration Query B is using parallelism: CPU > duration eg the query uses 2 CPUs, average 1.15 secs each Query A is probably not: CPU < duration This explains cost relative to batch: … Read more