Re: [GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread Alex Magnum
Hi Danish, yes thats the one I was looking for. Thanks a lot!!! On Tue, Jul 28, 2015 at 1:32 AM, dinesh kumar wrote: > > > On Mon, Jul 27, 2015 at 12:57 PM, dinesh kumar > wrote: > >> On Mon, Jul 27, 2015 at 12:53 PM, Alex Magnum >> wrote: >> >>> Hello, >>> >>> I have a csv string in a text f

Re: [GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread dinesh kumar
On Mon, Jul 27, 2015 at 12:57 PM, dinesh kumar wrote: > On Mon, Jul 27, 2015 at 12:53 PM, Alex Magnum > wrote: > >> Hello, >> >> I have a csv string in a text field that is unsorted and contains >> duplicates. >> Is there a simple way to remove these and sort the string. >> >> E.g >> 2,18,20,23,

Re: [GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread Chris Mair
> Hello, > > I have a csv string in a text field that is unsorted and contains > duplicates. > Is there a simple way to remove these and sort the string. > > E.g > 2,18,20,23,1,27,1,2,8,16,17,18,20,22,23,27 > > i tried string to array and unique but that did not work... > Any suggestions on ho

Re: [GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread Yves Dorfsman
> > I have a csv string in a text field that is unsorted and contains duplicates. > Is there a simple way to remove these and sort the string. > > E.g > 2,18,20,23,1,27,1,2,8,16,17,18,20,22,23,27 > Do you need to eventually load the data in Postgres? I'd personally use python to deal with th

Re: [GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread dinesh kumar
On Mon, Jul 27, 2015 at 12:53 PM, Alex Magnum wrote: > Hello, > > I have a csv string in a text field that is unsorted and contains > duplicates. > Is there a simple way to remove these and sort the string. > > E.g > 2,18,20,23,1,27,1,2,8,16,17,18,20,22,23,27 > > i tried string to array and uniqu

[GENERAL] Sorting CSV string and removing Duplicates

2015-07-27 Thread Alex Magnum
Hello, I have a csv string in a text field that is unsorted and contains duplicates. Is there a simple way to remove these and sort the string. E.g 2,18,20,23,1,27,1,2,8,16,17,18,20,22,23,27 i tried string to array and unique but that did not work... Any suggestions on how to do this without wri

Re: [GENERAL] Sorting rows by a column and storing a row number

2010-10-31 Thread Darren Duncan
Use the Postgres window functions like rank(); this is what they're for. http://www.postgresql.org/docs/8.4/interactive/queries-table-expressions.html#QUERIES-WINDOW -- Darren Duncan Alexander Farber wrote: Hello, I have a card game for each I'd like to introduce weekly tournaments. I'm going

[GENERAL] Sorting rows by a column and storing a row number

2010-10-31 Thread Alexander Farber
Hello, I have a card game for each I'd like to introduce weekly tournaments. I'm going to save the score (virtual money) won by each player into: create table pref_money ( id varchar(32) references pref_users, yw char(7) default to_char(current_timestamp, '

Re: [GENERAL] Sorting with materialized paths

2010-05-10 Thread Thomas Kellerer
Ovid wrote on 09.05.2010 15:33: My apologies. This isn't PG-specific, but since this is running on PostgreSQL 8.4, maybe there are specific features which might help. I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to s

Re: [GENERAL] Sorting with materialized paths

2010-05-10 Thread Alban Hertroys
On 10 May 2010, at 20:06, Greg Stark wrote: > On Sun, May 9, 2010 at 4:47 PM, Tom Lane wrote: >> Ovid writes: >>> My apologies. This isn't PG-specific, but since this is running on >>> PostgreSQL 8.4, maybe there are specific features which might help. >>> I have a tree structure in a table and

Re: [GENERAL] Sorting with materialized paths

2010-05-10 Thread Greg Stark
On Sun, May 9, 2010 at 4:47 PM, Tom Lane wrote: > Ovid writes: >> My apologies. This isn't PG-specific, but since this is running on >> PostgreSQL 8.4, maybe there are specific features which might help. >> I have a tree structure in a table and it uses materialized paths to allow >> me to find

Re: [GENERAL] Sorting with materialized paths

2010-05-10 Thread Peter Hunsberger
On Sun, May 9, 2010 at 8:33 AM, Ovid wrote: > My apologies. This isn't PG-specific, but since this is running on PostgreSQL > 8.4, maybe there are specific features which might help. > > I have a tree structure in a table and it uses materialized paths to allow me > to find children quickly. How

Re: [GENERAL] Sorting with materialized paths

2010-05-09 Thread Tom Lane
Ovid writes: > My apologies. This isn't PG-specific, but since this is running on PostgreSQL > 8.4, maybe there are specific features which might help. > I have a tree structure in a table and it uses materialized paths to allow me > to find children quickly. However, I also need to sort the res

[GENERAL] Sorting with materialized paths

2010-05-09 Thread Ovid
My apologies. This isn't PG-specific, but since this is running on PostgreSQL 8.4, maybe there are specific features which might help. I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread Baron Schwartz
Hi, On Tue, Feb 23, 2010 at 12:51 AM, Yang Zhang wrote: > When running the query in MySQL InnoDB: > > $ vmstat 10 > procs ---memory-- ---swap-- -io --system-- > -cpu-- >  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa > st >  0 13 137

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread Alex Hunsaker
On Tue, Feb 23, 2010 at 00:02, Yang Zhang wrote: > Thing is, this is how I got here: > > - ran complex query that does SELECT INTO. > - that never terminated, so killed it and tried a simpler SELECT (the > subject of this thread) from psql to see how long that would take. You might have better lu

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread Greg Stark
On Tue, Feb 23, 2010 at 9:48 AM, Yeb Havinga wrote: > Greg Stark wrote: >> >> You can do \set FETCH_COUNT to have psql use a cursor automatically. >> > > It seems like a big win in this case. What would be the downside of having a > fetch_count set default in psql? They were mentioned previously

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread Yeb Havinga
Greg Stark wrote: You can do \set FETCH_COUNT to have psql use a cursor automatically. It seems like a big win in this case. What would be the downside of having a fetch_count set default in psql? regards Yeb Havinga -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread John Gage
I am under the impression that MySQL does not have anything resembling Postgres' support for regular expressions. Though some might think that regular expressions are a sort of poor man's SQL, in any application which manages large amounts of text they are crucial. Postgres definitely doe

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-23 Thread Greg Stark
On Tue, Feb 23, 2010 at 6:48 AM, Scott Marlowe wrote: >> I'm relieved that Postgresql itself does not, in fact, suck, but >> slightly disappointed in the behavior of psql. I suppose it needs to >> buffer everything in memory to properly format its tabular output, >> among other possible reasons I

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Tue, Feb 23, 2010 at 1:48 AM, Scott Marlowe wrote: > On Mon, Feb 22, 2010 at 10:51 PM, Yang Zhang wrote: >> nOn Mon, Feb 22, 2010 at 3:45 PM, Scott Marlowe >> wrote: >>> >>> What do things like vmstat 10 say while the query is running on each >>> db?  First time, second time, things like

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Alex Hunsaker
On Mon, Feb 22, 2010 at 22:51, Yang Zhang wrote: > vmstat showed no swapping-out for a while, and then suddenly it > started spilling a lot. Checking psql's memory stats showed that it > was huge -- apparently, it's trying to store its full result set in > memory. As soon as I added a LIMIT 1,

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 10:51 PM, Yang Zhang wrote: > nOn Mon, Feb 22, 2010 at 3:45 PM, Scott Marlowe > wrote: >> >> What do things like vmstat 10 say while the query is running on each >> db?  First time, second time, things like that. > > Awesome -- this actually led me to discover the prob

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Tom Lane
Yang Zhang writes: > I'm relieved that Postgresql itself does not, in fact, suck, but > slightly disappointed in the behavior of psql. I suppose it needs to > buffer everything in memory to properly format its tabular output, > among other possible reasons I could imagine. That's half of it, and

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Tom Lane
Yang Zhang writes: >> # select count(1) from (SELECT * from metarelcould_transactionlog >> order by transactionid) as foo; > Does it strike anyone else that the query optimizer/rewriter should be > able to toss out the sort from such a query altogether? It could, if it knew that the aggregate fu

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 9:30 PM, Alex Hunsaker wrote: > On Mon, Feb 22, 2010 at 11:10, Yang Zhang wrote: >> I have the exact same table of data in both MySQL and Postgresql. In ?> >> Postgresql: > > FWIW on a stock (unchanged postgresql.conf) 8.3.9 I get (best of 3 > runs) 79 seconds, 26 using a

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
nOn Mon, Feb 22, 2010 at 3:45 PM, Scott Marlowe wrote: > On Mon, Feb 22, 2010 at 12:53 PM, Yang Zhang wrote: >> On Mon, Feb 22, 2010 at 2:52 PM, Scott Marlowe >> wrote: >>> On Mon, Feb 22, 2010 at 11:10 AM, Yang Zhang wrote: I have the exact same table of data in both MySQL and Postgr

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Alex Hunsaker
On Mon, Feb 22, 2010 at 11:10, Yang Zhang wrote: > I have the exact same table of data in both MySQL and Postgresql. In ?> > Postgresql: FWIW on a stock (unchanged postgresql.conf) 8.3.9 I get (best of 3 runs) 79 seconds, 26 using an index and 27 seconds with it clustered. Now yes it goes a lot

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 3:33 PM, Yang Zhang wrote: > On Mon, Feb 22, 2010 at 5:31 PM, Igor Neyman wrote: >> When in doubt - test. >> Why not remove index in MySQL (or create index in PostgreSQL) and see >> what happens. >> Why trying compare "apples and oranges"? > > Continue reading this thread

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 3:33 PM, Yang Zhang wrote: > On Mon, Feb 22, 2010 at 5:31 PM, Igor Neyman wrote: >> When in doubt - test. >> Why not remove index in MySQL (or create index in PostgreSQL) and see >> what happens. >> Why trying compare "apples and oranges"? > > Continue reading this thread

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 5:31 PM, Igor Neyman wrote: > When in doubt - test. > Why not remove index in MySQL (or create index in PostgreSQL) and see > what happens. > Why trying compare "apples and oranges"? Continue reading this thread -- I also tried using an index in Postgresql. -- Yang Zhang

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Igor Neyman
When in doubt - test. Why not remove index in MySQL (or create index in PostgreSQL) and see what happens. Why trying compare "apples and oranges"? Igor Neyman > -Original Message- > From: Yang Zhang [mailto:yanghates...@gmail.com] > Sent: Monday, February 22, 2010 1:37 PM > To: Richard

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Tom Lane
Yeb Havinga writes: > Just reading up on this interesting thread. WFIW, 2 years ago I and a > collegue of mine did a hardware comparison of early Intel and AMD > desktop quadcore processors to run postgres database, with most other > parts comparable. The intel processor was 20 to 30 % faster i

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 3:44 PM, Tom Lane wrote: > Yang Zhang writes: >> On Mon, Feb 22, 2010 at 1:13 PM, Pavel Stehule >> wrote: >>> the speed depends on setting of working_memory. Try to increase a >>> working_memory > >> It's already at >>  2kB > > According to your original posting, yo

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 12:53 PM, Yang Zhang wrote: > On Mon, Feb 22, 2010 at 2:52 PM, Scott Marlowe > wrote: >> On Mon, Feb 22, 2010 at 11:10 AM, Yang Zhang wrote: >>> I have the exact same table of data in both MySQL and Postgresql. In >>> Postgresql: >> >> Just wondering, are these on the s

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Tom Lane
Yang Zhang writes: > On Mon, Feb 22, 2010 at 1:13 PM, Pavel Stehule > wrote: >> the speed depends on setting of working_memory. Try to increase a >> working_memory > It's already at > 2kB According to your original posting, you're trying to sort something like a gigabyte of data. 20MB i

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yeb Havinga
Scott Marlowe wrote: On Mon, Feb 22, 2010 at 11:10 AM, Yang Zhang wrote: I have the exact same table of data in both MySQL and Postgresql. In Postgresql: Just wondering, are these on the same exact machine? Just reading up on this interesting thread. WFIW, 2 years ago I and a col

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:41 PM, Frank Heikens wrote: > > Op 22 feb 2010, om 20:28 heeft Yang Zhang het volgende geschreven: >> >> >>> >>> > If your work-mem is too low there's a good chance that Postgres has to > use your disks for sorting, which will obviously be quite slow. Re

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 12:50 PM, Yang Zhang wrote: > On Mon, Feb 22, 2010 at 2:39 PM, Scott Marlowe > wrote: >> On Mon, Feb 22, 2010 at 12:30 PM, Yang Zhang wrote: >>> This isn't some microbenchmark. This is part of our actual analytical >>> application. We're running large-scale graph partiti

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:52 PM, Scott Marlowe wrote: > On Mon, Feb 22, 2010 at 11:10 AM, Yang Zhang wrote: >> I have the exact same table of data in both MySQL and Postgresql. In >> Postgresql: > > Just wondering, are these on the same exact machine? > Yes, on the same disk. -- Yang Zhang htt

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 11:10 AM, Yang Zhang wrote: > I have the exact same table of data in both MySQL and Postgresql. In > Postgresql: Just wondering, are these on the same exact machine? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscripti

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:39 PM, Scott Marlowe wrote: > On Mon, Feb 22, 2010 at 12:30 PM, Yang Zhang wrote: >> This isn't some microbenchmark. This is part of our actual analytical >> application. We're running large-scale graph partitioning algorithms. > > It's important to see how it runs if yo

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Frank Heikens
Op 22 feb 2010, om 20:28 heeft Yang Zhang het volgende geschreven: If your work-mem is too low there's a good chance that Postgres has to use your disks for sorting, which will obviously be quite slow. Relative to the non-terminating 80-minute-so-far sort, Unix sort runs much faster

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Scott Marlowe
On Mon, Feb 22, 2010 at 12:30 PM, Yang Zhang wrote: > This isn't some microbenchmark. This is part of our actual analytical > application. We're running large-scale graph partitioning algorithms. It's important to see how it runs if you can fit more / most of the data set into memory by cranking

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:27 PM, Alvaro Herrera wrote: > Yang Zhang escribió: >> I have the exact same table of data in both MySQL and Postgresql. In >> Postgresql: > > I just noticed two things: > > [snip lots of stuff] > > 1. > >> ) ENGINE=MyISAM AUTO_INCREMENT=50410166 DEFAULT CHARSET=latin1 >

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Alvaro Herrera
Yang Zhang escribió: > I have the exact same table of data in both MySQL and Postgresql. In > Postgresql: I just noticed two things: [snip lots of stuff] 1. > ) ENGINE=MyISAM AUTO_INCREMENT=50410166 DEFAULT CHARSET=latin1 You're doing a comparison to MyISAM. 2. > select * from metarelclo

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:15 PM, Frank Heikens wrote: > > Op 22 feb 2010, om 20:07 heeft Yang Zhang het volgende geschreven: > >> On Mon, Feb 22, 2010 at 1:48 PM, Alban Hertroys >> wrote: >>> >>> On 22 Feb 2010, at 19:35, Yang Zhang wrote: >>> I also wouldn't have imagined an external merge-

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Frank Heikens
Op 22 feb 2010, om 20:07 heeft Yang Zhang het volgende geschreven: On Mon, Feb 22, 2010 at 1:48 PM, Alban Hertroys wrote: On 22 Feb 2010, at 19:35, Yang Zhang wrote: I also wouldn't have imagined an external merge-sort as being very Where's that external merge-sort coming from? Can you s

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 2:03 PM, Alvaro Herrera wrote: > Yang Zhang escribió: > >> I'm running: >> >>   select * from metarelcloud_transactionlog order by transactionid; >> >> It takes MySQL 6 minutes, but Postgresql is still running after 70 >> minutes. Is there something like a glaring misconfig

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 1:48 PM, Alban Hertroys wrote: > On 22 Feb 2010, at 19:35, Yang Zhang wrote: > >> I also wouldn't have imagined an external merge-sort as being very > > > Where's that external merge-sort coming from? Can you show an explain analyze? I just assumed that the "Sort" in the E

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Alvaro Herrera
Yang Zhang escribió: > I'm running: > > select * from metarelcloud_transactionlog order by transactionid; > > It takes MySQL 6 minutes, but Postgresql is still running after 70 > minutes. Is there something like a glaring misconfiguration that I'm > overlooking? Thanks in advance. How large i

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Alban Hertroys
On 22 Feb 2010, at 19:35, Yang Zhang wrote: > I also wouldn't have imagined an external merge-sort as being very Where's that external merge-sort coming from? Can you show an explain analyze? If your work-mem is too low there's a good chance that Postgres has to use your disks for sorting, whi

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Frank Heikens
Op 22 feb 2010, om 19:30 heeft Richard Broersma het volgende geschreven: On Mon, Feb 22, 2010 at 10:17 AM, Frank Heikens wrote: There is no index on the column transactionid in your PostgreSQL- table, as there is in your MySQL-table. This explains the difference. CREATE INDEX i_transacti

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 1:30 PM, Richard Broersma wrote: > On Mon, Feb 22, 2010 at 10:17 AM, Frank Heikens wrote: > >> There is no index on the column transactionid in your PostgreSQL-table, as >> there is in your MySQL-table. This explains the difference. >> >> CREATE INDEX i_transactionid ON pu

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
On Mon, Feb 22, 2010 at 1:13 PM, Pavel Stehule wrote: > hello > > the speed depends on setting of working_memory. Try to increase a > working_memory > > set working_memory to '10MB'; It's already at tpcc=# show work_mem; work_mem -- 2kB (1 row) I also wouldn't have imagined an ex

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Richard Broersma
On Mon, Feb 22, 2010 at 10:17 AM, Frank Heikens wrote: > There is no index on the column transactionid in your PostgreSQL-table, as > there is in your MySQL-table. This explains the difference. > > CREATE INDEX i_transactionid ON public.metarelcloud_transactionlog > (transactionid); Does an inde

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Frank Heikens
There is no index on the column transactionid in your PostgreSQL- table, as there is in your MySQL-table. This explains the difference. CREATE INDEX i_transactionid ON public.metarelcloud_transactionlog (transactionid); Op 22 feb 2010, om 19:10 heeft Yang Zhang het volgende geschreven: I h

Re: [GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Pavel Stehule
hello the speed depends on setting of working_memory. Try to increase a working_memory set working_memory to '10MB'; Regards Pavel Stehule 2010/2/22 Yang Zhang : > I have the exact same table of data in both MySQL and Postgresql. In > Postgresql: > > tpcc=# \d metarelcloud_transactionlog >    

[GENERAL] Sorting performance vs. MySQL

2010-02-22 Thread Yang Zhang
I have the exact same table of data in both MySQL and Postgresql. In Postgresql: tpcc=# \d metarelcloud_transactionlog Table "public.metarelcloud_transactionlog" Column| Type | Modifiers -+---

[GENERAL] Sorting JTA survey results

2008-11-20 Thread wstrzalka
http://www.postgresqlcertification.org/jta/2008/results Having point 4 as an example: For how long have you been a PostgreSQL database administrator? Less than 1 year36 I wish.

Re: [GENERAL] Sorting nulls and empty strings together

2008-04-29 Thread Gregory Stark
"Andrus" <[EMAIL PROTECTED]> writes: > User interface need to show nulls as empty strings. > PostgreSQL sorts nulls after all data. >... > Select statements are generated dynamically by driver and it is not easy > to change them to generate order by coalesce( testcol,''). You could use NULLS FIRS

Re: [GENERAL] Sorting nulls and empty strings together

2008-04-29 Thread Martijn van Oosterhout
On Mon, Apr 28, 2008 at 08:05:45PM +0300, Andrus wrote: > User interface need to show nulls as empty strings. > PostgreSQL sorts nulls after all data. > > create temp table test ( testcol char(10) ); > insert into test values ( null); > insert into test values ( 'test'); > insert into test values

[GENERAL] Sorting nulls and empty strings together

2008-04-29 Thread Andrus
User interface need to show nulls as empty strings. PostgreSQL sorts nulls after all data. create temp table test ( testcol char(10) ); insert into test values ( null); insert into test values ( 'test'); insert into test values ( ''); select * from test order by testcol; This confuses users who e

Re: [GENERAL] Sorting nulls and empty strings together

2008-04-28 Thread Dennis Muhlestein
Andrus wrote: User interface need to show nulls as empty strings. PostgreSQL sorts nulls after all data. create temp table test ( testcol char(10) ); insert into test values ( null); insert into test values ( 'test'); insert into test values ( ''); select * from test order by testcol; This conf

Re: [GENERAL] Sorting

2007-01-08 Thread Bart McFarling
Thanks, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andreas Kretschmer Sent: Monday, January 08, 2007 11:19 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Sorting Ragnar <[EMAIL PROTECTED]> schrieb: > > test=*# select w,

Re: [GENERAL] Sorting

2007-01-08 Thread Andreas Kretschmer
Ragnar <[EMAIL PROTECTED]> schrieb: > > test=*# select w, case when w ~ '^[0-9]*$' then w::int else 1 end from > > foo order by 2,1; > > possible improvements: > a) w ~ '^[0-9]+$' > b) use NULL instead of 1 Thanks, right. Andreas -- Really, I'm not out to destroy Microsoft. That w

Re: [GENERAL] Sorting

2007-01-08 Thread Ragnar
On mán, 2007-01-08 at 17:59 +0100, A. Kretschmer wrote: > am Mon, dem 08.01.2007, um 10:21:38 -0600 mailte Bart McFarling folgendes: > > I have a column that is a varchar(6) I need to sort it by the rows that are > > integers 1st then the character ones or vice versa, I just need the values > > t

Re: [GENERAL] Sorting

2007-01-08 Thread A. Kretschmer
am Mon, dem 08.01.2007, um 10:21:38 -0600 mailte Bart McFarling folgendes: > I have a column that is a varchar(6) I need to sort it by the rows that are > integers 1st then the character ones or vice versa, I just need the values > that > can be converted to integer to sort by their numeric value

[GENERAL] Sorting

2007-01-08 Thread Bart McFarling
I have a column that is a varchar(6) I need to sort it by the rows that are integers 1st then the character ones or vice versa, I just need the values that can be converted to integer to sort by their numeric value. i.e 1, 2, 3, 4, 5, 10, 11, A, B, C instead of 1, 10, 11, 2, 3, 4, 5, A, B, C An

Re: [GENERAL] Sorting with DISTINCT ON

2007-01-08 Thread Nico Grubert
It does allow you to sort on both columns. SELECT DISTINCT ON (path) path, comment_id, created, title FROM bewertungen.tblcomments ORDER BY path, created Thank you very much. Works perfect! :-) ---(end of broadcast)--- TIP 3: Have you

Re: [GENERAL] Sorting with DISTINCT ON

2007-01-08 Thread Jorge Godoy
Nico Grubert <[EMAIL PROTECTED]> writes: > My first try was this SQL query: > > SELECT DISTINCT ON (path) path, comment_id, created, title > FROM bewertungen.tblcomments > > This does not allow me to append "ORDER BY created" since I can only sort on > path because of DISTINCT ON (path). I

[GENERAL] Sorting with DISTINCT ON

2007-01-08 Thread Nico Grubert
Hi there, I have a problem sorting a SQL result if I use DISTINCT ON. I have a table "tblcomment" with these columns: id (serial) path (varchar) created (timestamp) title (varchar) These records are in the table "tblcomment": id pathcreated title --

Re: [GENERAL] Sorting array field

2005-12-22 Thread David Fetter
On Thu, Dec 22, 2005 at 08:38:46AM -0700, Pete Deffendol wrote: > Hi, > > Can anyone point me toward an SQL function (whether built-in or an > add-on) that will allow me to sort the contents of an array datatype > in an SQL query? > > Something like this: > > select sort(my_array_field) from my_

Re: [GENERAL] Sorting array field

2005-12-22 Thread Michael Fuhr
On Thu, Dec 22, 2005 at 08:38:46AM -0700, Pete Deffendol wrote: > Can anyone point me toward an SQL function (whether built-in or an add-on) > that will allow me to sort the contents of an array datatype in an SQL > query? For integer arrays see contrib/intarray. SELECT sort('{5,2,3,1,9,7}'::int[

[GENERAL] Sorting array field

2005-12-22 Thread Pete Deffendol
Hi, Can anyone point me toward an SQL function (whether built-in or an add-on) that will allow me to sort the contents of an array datatype in an SQL query? Something like this: select sort(my_array_field) from my_table; Thanks! Pete

Re: [GENERAL] Re: [GENERAL] Sorting problems with SELECT * FROM

2005-10-31 Thread Daniel Verite
Nico Grubert wrote: > Ah, I found it: > > lc_collate: [EMAIL PROTECTED] > lc_ctype: [EMAIL PROTECTED] This is an iso-8859-15 locale, isn't it? If your database encoding is UNICODE, I believe you'd have more success using an UTF8 locale, such as de_DE.UTF-8 in your case. -- Dani

[GENERAL] Re: [GENERAL] Sorting problems with SELECT * FROM table WHERE name LIKE 'Ö %'

2005-10-31 Thread Nico Grubert
I have a problem when sorting records with: SELECT * FROM table WHERE name LIKE 'Ö%' I am running Postgres 8.02 with a database whose character encoding is UNICODE. The SQL Query SELECT * FROM member WHERE name LIKE 'O%' OR name like 'Ö%' ORDER BY name re

[GENERAL] Re: [GENERAL] Sorting problems with SELECT * FROM table WHERE name LIKE 'Ö %'

2005-10-30 Thread Nico Grubert
Ah, I found it: lc_collate: [EMAIL PROTECTED] lc_ctype: [EMAIL PROTECTED] ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

[GENERAL] Re: [GENERAL] Sorting problems with SELECT * FROM table WHERE name LIKE 'Ö %'

2005-10-30 Thread Nico Grubert
... but what locale is it using? (See LC_COLLATE and LC_CTYPE.) Can I find out out these settings in "phpPgAdmin"? Or can I use LC_COLLATE and LC_CTYPE in the SQL Query? ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ig

Re: [GENERAL] Sorting problems with SELECT * FROM table WHERE name LIKE 'Ö%'

2005-10-30 Thread Tom Lane
Nico Grubert <[EMAIL PROTECTED]> writes: > I have a problem when sorting records with: > SELECT * FROM table WHERE name LIKE 'Ö%' > I am running Postgres 8.02 with a database whose character encoding is > UNICODE. ... but what locale is it using? (See LC_COLLATE and LC_CTYPE.)

[GENERAL] Sorting problems with SELECT * FROM t able WHERE name LIKE 'Ö%'

2005-10-30 Thread Nico Grubert
Hi there, I have a problem when sorting records with: SELECT * FROM table WHERE name LIKE 'Ö%' I am running Postgres 8.02 with a database whose character encoding is UNICODE. The SQL Query SELECT * FROM member WHERE name LIKE 'O%' OR name like 'Ö%' ORDER BY

Re: [GENERAL] Sorting by related tables

2005-08-15 Thread Bill Moseley
On Mon, Aug 15, 2005 at 11:30:32PM +0200, Andreas Seltenreich wrote: > > This would be one possibility. If you don't want your application to > deal with transactions being aborted because of non-serializable > transactions, you could alternatively use explicit locking (SELECT ... > FOR UPDATE) co

Re: [GENERAL] Sorting by related tables

2005-08-15 Thread Andreas Seltenreich
Bill Moseley schrob: > On Sat, Aug 13, 2005 at 06:44:09PM +0200, Andreas Seltenreich wrote: >> > 3) Oh, and I have also this for checking IF there are items in >> > "region" that are "above" the item in question -- to see IF an item >> > can or cannot be moved up in the sort order relative to othe

Re: [GENERAL] Sorting by related tables

2005-08-15 Thread Bill Moseley
On Sat, Aug 13, 2005 at 06:44:09PM +0200, Andreas Seltenreich wrote: > > 3) Oh, and I have also this for checking IF there are items in > > "region" that are "above" the item in question -- to see IF an item > > can or cannot be moved up in the sort order relative to others. > > > > SELECT id F

Re: [GENERAL] Sorting by related tables

2005-08-13 Thread Andreas Seltenreich
Bill Moseley schrob: > create table region { > id SERIAL PRIMARY KEY, > nametext, > -- order this table should be sorted in > -- a "1" is the top sort level > sort_order integer > ); > > create table city { > id SERIAL PRIMARY KEY, > nametext,

[GENERAL] Sorting by related tables

2005-08-13 Thread Bill Moseley
I have a few beginner questions about using related tables for sorting. create table region { id SERIAL PRIMARY KEY, nametext, -- order this table should be sorted in -- a "1" is the top sort level sort_order integer ); create table city { id SERIAL

Re: [GENERAL] Sorting by constant values

2005-05-03 Thread Ragnar Hafstað
On Tue, 2005-05-03 at 13:29 -0400, Robert Fitzpatrick wrote: > I have a column that I want to sort by certain values. The values are > Unit, Exterior and Common. I want all the records with Unit first, > Common second and Exterior last in the sort order. These are the only 3 > possible values, is t

Re: [GENERAL] Sorting by constant values

2005-05-03 Thread Scott Marlowe
On Tue, 2005-05-03 at 12:29, Robert Fitzpatrick wrote: > I have a column that I want to sort by certain values. The values are > Unit, Exterior and Common. I want all the records with Unit first, > Common second and Exterior last in the sort order. These are the only 3 > possible values, is there a

Re: [GENERAL] Sorting by constant values

2005-05-03 Thread Franco Bruno Borghesi
You can order by conditions, lets say column='Unit'. The evaluation of a conditions will give you 't' or 'f', and alfabetically 'f' < 't'... you should use DESC to get the matches first. So, it would be more or less like this: ORDER BY    column='Unit' DESC,    column='Exterior' DESC,    column='C

[GENERAL] Sorting by constant values

2005-05-03 Thread Robert Fitzpatrick
I have a column that I want to sort by certain values. The values are Unit, Exterior and Common. I want all the records with Unit first, Common second and Exterior last in the sort order. These are the only 3 possible values, is there a way to sort manually like that with the alphanumeric values?

Re: [GENERAL] sorting Chinese varchar field

2005-03-28 Thread Tatsuo Ishii
> Great, that works out fine! > > So, the SQL I tested with is: > select * from mytable order by convert(name, 'utf8', 'gb18030'); Sorry, what I wanted to say was: SELECT * FROM t1 WHERE ... ORDER BY CONVERT(your_chinese_character using utf_8_to_gb_18030); Of course your example is fine too (a

Re: [GENERAL] sorting Chinese varchar field

2005-03-28 Thread jian chen
Great, that works out fine! So, the SQL I tested with is: select * from mytable order by convert(name, 'utf8', 'gb18030'); It produces the correct output. Thanks Tatsuo! Jian On Tue, 29 Mar 2005 10:25:58 +0900 (JST), Tatsuo Ishii <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I installed postgres

Re: [GENERAL] sorting Chinese varchar field

2005-03-28 Thread Tatsuo Ishii
> Hi, > > I installed postgres 8.0 for windows on my win xp (Simplified Chinese > version). The encoding is unicode. When I set pgsql client encoding to > gb18030, I could insert Chinese text from the command line to > postgres. > > However, I could not get the sort order of Chinese varchar field

Re: [GENERAL] sorting Chinese varchar field

2005-03-28 Thread Magnus Hagander
>Hi, > >I installed postgres 8.0 for windows on my win xp (Simplified Chinese >version). The encoding is unicode. When I set pgsql client encoding to >gb18030, I could insert Chinese text from the command line to >postgres. > >However, I could not get the sort order of Chinese varchar field to >wor

[GENERAL] sorting Chinese varchar field

2005-03-28 Thread jian chen
Hi, I installed postgres 8.0 for windows on my win xp (Simplified Chinese version). The encoding is unicode. When I set pgsql client encoding to gb18030, I could insert Chinese text from the command line to postgres. However, I could not get the sort order of Chinese varchar field to work properl

Re: [GENERAL] Sorting when '*' is the initial character - solved

2005-02-08 Thread Berend Tober
> On Tue, 8 Feb 2005 01:10 pm, CoL wrote: >> hi, >> >> Berend Tober wrote, On 2/7/2005 22:20: >> > I encountered what looks like unusually sorting behavior, and I'm >> wondering if >> > anyone can tell me if this is supposted to happen (and then if so, why) or >> if >> > this is a bug: ---

Re: [GENERAL] Sorting when "*" is the initial character

2005-02-08 Thread Russell Smith
On Tue, 8 Feb 2005 01:10 pm, CoL wrote: > hi, > > Berend Tober wrote, On 2/7/2005 22:20: > > I encountered what looks like unusually sorting behavior, and I'm wondering > > if > > anyone can tell me if this is supposted to happen (and then if so, why) or > > if > > this is a bug: > > > > > > S

Re: [GENERAL] Sorting when "*" is the initial character

2005-02-07 Thread CoL
hi, Berend Tober wrote, On 2/7/2005 22:20: I encountered what looks like unusually sorting behavior, and I'm wondering if anyone can tell me if this is supposted to happen (and then if so, why) or if this is a bug: CREATE TABLE sample_table ( account_id varchar(4), account_name varchar(25) ) WI

Re: [GENERAL] Sorting when "*" is the initial character

2005-02-07 Thread Stephan Szabo
On Mon, 7 Feb 2005, Berend Tober wrote: > I encountered what looks like unusually sorting behavior, and I'm wondering if > anyone can tell me if this is supposted to happen (and then if so, why) or if > this is a bug: If you ran initdb with a locale such as en_US, a result like what you got is ex

Re: [GENERAL] Sorting when "*" is the initial character

2005-02-07 Thread Bruno Wolff III
On Mon, Feb 07, 2005 at 16:20:36 -0500, Berend Tober <[EMAIL PROTECTED]> wrote: > > SELECT * FROM sample_table ORDER BY 1; > > account_id,account_name > 100,First account > 110,Second account > *115,Fifth account > 120,Third account > *125,Fourth account > > I would expect to see > > account_

  1   2   >