Skip to content

Execution plan

RCSI with foreign keys, NULL values and paramater sniffing behavior

In this blog post let’s go back to the roots (DBA concern) with a discussion with one of my friends about a weird transaction locking issue. In fact, this discussion was specifically around two questions. The first one was why SQL Server continues to use shared locks in RCSI mode leading to blocking scenarios and the second one was about… 

Postgres vs. Oracle access paths XI – Sample Scan

By Franck Pachot . I was going to end this series with the previous post because the last access path available in Postgres is a bit special: a Seq Scan that returns only a sample of the rows, at random. However, it is the occasion to come back to the difference between random and sequential reads. I’m still working on… 

Postgres vs. Oracle access paths X – Update

By Franck Pachot . In the previous post we have seen the cheapest way to get one row, reading only one block from its physical location. But that’s the optimal case where the row has not moved. I’ll (nearly) conclude this series about access path with an update. ROWID in Oracle Here is the ROWID of one row in Oracle:… 

Postgres vs. Oracle access paths IX – Tid Scan

By Franck Pachot . In the previous post we have seen how Postgres and Oracle finds the table row from the index entry. It uses the TID / ROWID. I’ll focus on this access path and I will have covered all Postgres access paths to table data. Oracle ACCESS BY ROWID I start with Oracle because we already have seen… 

Postgres vs. Oracle access paths VIII – Index Scan and Filter

By Franck Pachot . In the previous post we have seen a nice optimization to lower the consequences of bad correlation between the index and the table physical order: a bitmap, which may include false positives and then requires a ‘recheck’ of the condition, but with the goal to read each page only once. Now we are back to the… 

Postgres vs. Oracle access paths VI – Index Scan

By Franck Pachot . In the previous post my queries were still reading the indexed column only, from a table which had no modifications since the last vacuum, and then didn’t need to read table pages: it was Index Only Scan. However, we often need more columns than the ones that are in the index. Here is the Index Scan… 

Postgres vs. Oracle access paths V – FIRST ROWS and MIN/MAX

By Franck Pachot . We have seen how an index can help to avoid a sorting operation in the previous post. This avoids a blocking operation: the startup cost is minimal and the first rows can be immediately returned. This is often desired when displaying rows to the user screen. Here is more about Postgres startup cost, Oracle first_rows costing,… 

Postgres vs. Oracle access paths IV – Order By and Index

By Franck Pachot . I realize that I’m talking about indexes in Oracle and Postgres, and didn’t mention yet the best website you can find about indexes, with concepts and examples for all RDBMS: http://use-the-index-luke.com. You will probably learn a lot about SQL design. Now let’s continue on execution plans with indexes. As we have seen two posts ago, an… 

Postgres vs. Oracle access paths III – Partial Index

By Franck Pachot . In the previous post I said that an Index Only Access needs to find all rows in the index. Here is a case where, with similar data, Postgres can find all rows but Oracle needs additional considerations. In the previous post I’ve executed: select sum(n) from demo1 The execution plan was: Aggregate (cost=295.29..295.30 rows=1 width=8) (actual… 

Postgres vs. Oracle access paths II – Index Only Scan

By Franck Pachot . In the previous post I’ve explained a sequential scan by accident: my query needed only one column which was indexed, and I expected to read the index rather than the table. And I had to hint the Oracle example to get the same because the Oracle optimizer chooses the index scan over the table scan in… 

Postgres vs. Oracle access paths I – Seq Scan

By Franck Pachot . Here is the first test I’ve done for my Postgres vs. Oracle access paths series and the first query did a sequential scan. It illustrates the first constant you find in the documentation for the query planner: seq_page_cost (floating point) Sets the planner’s estimate of the cost of a disk page fetch that is part of… 

Postgres vs. Oracle access paths – intro

By Franck Pachot . This is the start of a series on PostgreSQL execution plans, access path, join methods, hints and execution statistics. The approach will compare Postgres and Oracle. It is not a comparison to see which one is better, but rather to see what is similar and where the approaches diverge. I have a long experience of reading…