Re: [SQL] UPDATE COMPATIBILITY

2012-01-17 Thread Samuel Gendler
On Tue, Jan 17, 2012 at 12:49 AM, Thomas Kellerer wrote: > Gera Mel Handumon, 17.01.2012 07:31: > > What version of postgresql that the update compatibility below will be >> implemented? >> >> UPDATE COMPATIBILITY >> >> >> UPDATE accounts SET (contact_last_name, contact_first_name) = >> (SELE

Re: [SQL] Wrong query plan when using a left outer join

2012-01-17 Thread Rosser Schwarz
2012/1/17 Filip Rembiałkowski : > postgres will still try to choose best execution plan. seq scan may simply be > faster here. breaking point is somewhere near 50% selectivity. The tipping point is usually far lower than that; in fact, it's more often around 10%. Random IO is *very* expensive, a

Re: [SQL] Wrong query plan when using a left outer join

2012-01-17 Thread Feike Steenbergen
oops, but ofcourse, a natural view will not give the correct answer, back to the drawing board ... On Tue, Jan 17, 2012 at 19:53, Feike Steenbergen wrote: >> BTW, add a foreign key and index on handhistory_plain.hand_id (unless> you >> have it already). > It's there already: > > feiketracker=# \

Re: [SQL] Wrong query plan when using a left outer join

2012-01-17 Thread Feike Steenbergen
> BTW, add a foreign key and index on handhistory_plain.hand_id (unless> you > have it already). It's there already: feiketracker=# \d+ handhistory_plain; Table "stage.handhistory_plain" Column | Type | Modifiers | Storage | Description -+-+---+--

Re: [SQL] UPDATE COMPATIBILITY

2012-01-17 Thread Thomas Kellerer
Adrian Klaver, 17.01.2012 16:19: You need to rewrite it to: UPDATE accounts SET contact_last_name = s.last_name, contact_first_name = s.first_name FROM salesmen s WHERE s.id = accounts.sales_id For completeness, you could also do: UPDATE accounts SET (contact_last_name,cont

Re: [SQL] UPDATE COMPATIBILITY

2012-01-17 Thread Adrian Klaver
On Tuesday, January 17, 2012 12:49:44 am Thomas Kellerer wrote: > Gera Mel Handumon, 17.01.2012 07:31: > > None as far as I know. > > You need to rewrite it to: > > UPDATE accounts >SET contact_last_name = s.last_name, >contact_first_name = s.first_name > FROM salesmen s > WHERE s.i

Re: [SQL] sql query problem

2012-01-17 Thread David Johnston
On Jan 17, 2012, at 8:35, Andreas Kretschmer wrote: > Alok Thakur wrote: > >> Dear, >> >> I am trying to provide you as much details as possible. >> >> answer` ( >> `id` int(10) NOT NULL AUTO_INCREMENT, >> `question_id` int(10) NOT NULL, >> `user_id` int(10) NOT NULL, >> `answer` int(10)

Re: [SQL] sql query problem

2012-01-17 Thread Andreas Kretschmer
Alok Thakur wrote: > Dear, > > I am trying to provide you as much details as possible. > > answer` ( > `id` int(10) NOT NULL AUTO_INCREMENT, > `question_id` int(10) NOT NULL, > `user_id` int(10) NOT NULL, > `answer` int(10) NOT NULL, -> > `status` tinyint(1) NOT NULL, --> Status wil

Re: [SQL] Wrong query plan when using a left outer join

2012-01-17 Thread Filip Rembiałkowski
On Tue, Jan 17, 2012 at 7:54 AM, Feike Steenbergen wrote: > I have the following setup: > > A table called hand: > > >                                        Table "stage.hand_meta" >    Column     |           Type           | > Modifiers > ---+--+--

Re: [SQL] sql query problem

2012-01-17 Thread Alok Thakur
Dear, I am trying to provide you as much details as possible. answer` ( `id` int(10) NOT NULL AUTO_INCREMENT, `question_id` int(10) NOT NULL, `user_id` int(10) NOT NULL, `answer` int(10) NOT NULL, -> `status` tinyint(1) NOT NULL, --> Status will be 0 or 1 means wrong or right answer

Re: [SQL] Query Problem... Left OuterJoin / Tagging Issue

2012-01-17 Thread John Tuliao
Thank you so much for your prompt reply David. I will consider your advice and put it to mind and action. I hope you all don't get tired of helping! For now, I will note down what I need to and do the necessary adjustments. Thank you for your time! On Friday, 13 January, 2012 10:26 PM, David

Re: [SQL] UPDATE COMPATIBILITY

2012-01-17 Thread Thomas Kellerer
Gera Mel Handumon, 17.01.2012 07:31: What version of postgresql that the update compatibility below will be implemented? UPDATE COMPATIBILITY UPDATE accounts SET (contact_last_name, contact_first_name) = (SELECT last_name, first_name FROM salesmen WHERE salesmen.id = accounts.sales_