Home Query execution plan
Post
Cancel

Query execution plan

PostgreSQL

TypeDescription
Seq scanFull scan
When index doesn’t exist, or expected rows are large (greater than 5~10%)
Index scanSearch by key and retrieves data located in heap (Always RID Lookup)
Index only scanSearch only keys (covering index)

Postgres uses only non-clustered index (secondary index).
RID lookup always occurs when executing index scan.

SQL Server

TypeDescription
Table scanFull scan
when table without a clustered index is accessed.
Clustered Index scanClustered index exists but query can’t use non-clustered index
Clustered Index seekScan limited set of rows using B tree structure clustered index.
Non-Clustered Index scanTable has non-clustered index but query requires accessing a large amount of data across particular index
Non-Clustered Index seekQuery accesses data using B+ tree index (No Lookup, Covering index)
LookupQuery requires accessing not exists in B+ tree
=> RID/Key lookup
=> Random I/O occurs.

📝 Clustered Index scan is not good because even though the table has clustered index, it’s not used for searching really.
This would lead to a performance degradation.
In SQL Server, Index scan and table scan are not so different in terms of performance.


🔗 References

This post is licensed under CC BY 4.0 by the author.

Database Partitioning

Don't use DB as Container

Trending Tags