This is the answer to the comment from @Twelfth , as well as the question itself.
Three quotes from this chapter in the manual:
" Managing the Scheduler with Explicit JOIN Clauses "
The explicit syntax of the inner join ( INNER JOIN , CROSS JOIN or unadorned JOIN ) semantically matches the enumeration of input relations in FROM , and therefore does not limit the join order.
...
To force the scheduler to follow the join order set forth by explicit JOIN s, set the join_collapse_limit time join_collapse_limit to 1. (Other possible values โโare discussed below.)
...
Limiting the search for the scheduler in this way is a useful method both to reduce planning time and to direct the scheduler to a good query plan .
My bold accent. Conversely, you can abuse the same to direct the query planner to a poor query plan for testing purposes. Read the entire manual page. This should be helpful.
In addition, you can force nested loops to disable alternative methods one by one (best in your session). How:
SET enable_hashjoin = off;
Etc.
About verification and settings:
- Request a parameter (postgresql.conf parameter), for example, "max_connections",
Forced errors in the actual assessment
One obvious way would be to disable autovacuum and add / remove rows from the table. Then the query planner works with outdated statistics. Please note that some other commands also update statistics.
Statistics are stored in the catalog tables pg_class and pg_statistics .
SELECT * FROM pg_class WHERE oid = 'mytable'::regclass; SELECT * FROM pg_statistic WHERE starelid = 'mytable'::regclass;
This leads me to another option. You can fake entries in these two tables. Superuser privilege required.
You do not attack me as new, but a warning to the general public: if you break something in the catalog tables, your database (cluster) may move up. You have been warned.
Erwin Brandstetter Jul 28 '14 at 19:36 2014-07-28 19:36
source share