Skip site navigation (1) Skip section navigation (2)

Re: proposal: Preference SQL

From: "Stephen R(dot) van den Berg" <srb(at)cuci(dot)nl>
To: Jan Urba??ski <j(dot)urbanski(at)students(dot)mimuw(dot)edu(dot)pl>
Cc: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: Preference SQL
Date: 2008-05-31 09:04:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Jan Urba??ski wrote:
>Preference SQL is an extension to regular SQL, that allows expressing 
>preferences in SQL queries. Preferences are like "soft" WHERE clauses. A 
>preference doesn't need to be satisfied by a tuple for it to appear in 
>the result set, but it's "preferred" it is. More strictly, a set of 
>preference clauses in a SQL query defines a partial order on the result 
>set as it would appear without any preference clauses and then returns 
>the maximal elements.

>An example of a preference query would be (quoting the linked PDF):

>SELECT * FROM programmers PREFERRING exp IN (???java???, ???C++???);
>SELECT * FROM computers
>PREFERRING HIGHEST(main_memory) AND HIGHEST(cpu_speed);

Forgive my ignorance, but it appears that this can already be achieved
by using a properly weighted ORDER BY clause, as in:

SELECT * FROM computers
ORDER BY HIGHEST(main_memory) DESC, HIGHEST(cpu_speed) DESC;
Sincerely,                                                          srb(at)cuci(dot)nl
           Stephen R. van den Berg.

"Sleep: A completely inadequate substitute for caffeine."

In response to


pgsql-hackers by date

Next:From: Jan UrbańskiDate: 2008-05-31 11:33:54
Subject: Re: proposal: Preference SQL
Previous:From: Simon RiggsDate: 2008-05-31 07:34:34
Subject: Re: Overhauling GUCS

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group