Planner hints in SELECT queries?

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Planner hints in SELECT queries?
Date: 2008-12-17 14:30:04
Message-ID: d7df81620812170630t70d0117fka7866892f01435d4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

Sometimes I have to create the following SQL code:

SET something=off;
SET other=off;
SELECT * FROM ... ORDER BY id LIMIT 10;
RESET something;
RESET something;

(e.g. "something" may be equal to "seq_page_cost=100000").

I propose to add the SELECT clause to do it natively, like this:

SELECT *
FROM tbl
ORDER BY id
LIMIT 10
SETTING something=off, other=off

This will do RESET back automatically when the query is executed.

(Why do I need it? Because sometimes even after ANALYZE query I get
non-optimal plan, even if I exactly know which plan should be used.)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2008-12-17 14:44:14 Re: Is this a security risk?
Previous Message Marc Schablewski 2008-12-17 14:06:39 Re: PostgreSQL installation