Re: proposal: Preference SQL - Mailing list pgsql-hackers

From Stephen R. van den Berg
Subject Re: proposal: Preference SQL
Date
Msg-id 20080531090442.GB8631@cuci.nl
Whole thread Raw
In response to proposal: Preference SQL  (Jan Urbański <j.urbanski@students.mimuw.edu.pl>)
Responses Re: proposal: Preference SQL  (Jan Urbański <j.urbanski@students.mimuw.edu.pl>)
List 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++???);
>or
>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@cuci.nl          Stephen R. van den Berg.

"Sleep: A completely inadequate substitute for caffeine."


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Overhauling GUCS
Next
From: Jan Urbański
Date:
Subject: Re: proposal: Preference SQL