Re: [GENERAL] Prevent out of memory errors by reducing work_mem?

2013-01-27 Thread Jan Strube
Hi, you are right. We were running 9.1.4 and after upgrading to 9.1.7 the error disappeared. Thanks a lot, JanStrube I'm getting an out of memory error running the following query over 6 tables (the *BASE* tables have over 1 million rows each) on Postgresql 9.1. The machine has 4GB RAM: It l

Re: [GENERAL] Optimizing select count query which often takes over 10 seconds

2013-01-27 Thread Jeff Janes
On Sun, Jan 27, 2013 at 9:25 AM, Alexander Farber wrote: > Hello - > > On Fri, Jan 25, 2013 at 7:42 PM, Jeff Janes wrote: >> This sounds like a good idea. But if the tournament is weekly why >> would the job have to be hourly? Why do the results of a weekly >> tournament need to be 'live'? > >

Re: [GENERAL] Finding common hstore key=>value pairs with hstore

2013-01-27 Thread Jeff Janes
On Sun, Jan 27, 2013 at 3:09 AM, Paul Norman wrote: > I am in a situation where I have two tables, a and b, each with a hstore > column called tags. Both tags columns have a GIN index on them. I want to > find rows of a and b where the both have a particular hstore key and that > key is the same.

Re: [GENERAL] Optimizing select count query which often takes over 10 seconds

2013-01-27 Thread Alexander Farber
Hello - On Fri, Jan 25, 2013 at 7:42 PM, Jeff Janes wrote: > On Thu, Jan 24, 2013 at 1:57 AM, Alexander Farber > wrote: >> >> LOG: duration: 12590.394 ms statement: >> select count(id) from ( >> select id, >>row_number() over(partition by yw order by mon

[GENERAL] Best approach for query with optional constraints

2013-01-27 Thread Jon Smark
Hi, I have a problem with multiple solutions, and my question concerns which solution is preferred given whatever optimizations happen inside the query planner. In a bug tracking system, I have the tables "users", "bugs" and "tags". One bug may have one user (the reporter) but multiple tags.  Mor

Re: [GENERAL] Postfresql 8.4 Problem

2013-01-27 Thread Adrian Klaver
On 01/25/2013 07:02 AM, Electric Boy wrote: I have a problem with posgresql 8.4, yesterday when I tried to reinstall and do restore the old database not work if you install in a different folder than the folder given the old database, the program works. When installing program the old folder wher

Re: [GENERAL] Restore 1 Table from pg_dumpall?

2013-01-27 Thread Ondrej Ivanič
Hi, On 23 January 2013 04:57, Rich Shepard wrote: > Is there a way I can extract a single table's schema and data from the > full backup? If so, I can then drop the fubar'd table and do it correctly > this time. You should grep for: - CREATE TABLE - COPY statements and then note line numbers

Re: [GENERAL] seeking SQL book recommendation

2013-01-27 Thread Rich Shepard
On Thu, 24 Jan 2013, Bruno Wolff III wrote: For a client who needs to learn how to query the db: I found the postgresql documentation very useful for learning SQL. Two more suggestions: Rick van der Lans' 'Introduction to SQL, 4th Edition' for its comprehensiveness and extensive discussio

Re: [GENERAL] Restore 1 Table from pg_dumpall?

2013-01-27 Thread Rich Shepard
On Sun, 27 Jan 2013, Jasen Betts wrote: yeah, emacs is slow on large files. Jasen, I've noticed this over the years. for a one-off I'd use less(1), to extract the desired table data. If I had to repeat it i'd use sed or awk I used 'joe'. It handled the job with aplomb. Thanks, Rich

Re: [GENERAL] Finding common hstore key=>value pairs with hstore

2013-01-27 Thread Paul Norman
> From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of John R Pierce > Subject: Re: [GENERAL] Finding common hstore key=>value pairs with > hstore > > On 1/27/2013 3:09 AM, Paul Norman wrote: > > I am in a situation where I have two tables, a and b,

Re: [GENERAL] Yet Another Timestamp Question: Time Defaults

2013-01-27 Thread Jasen Betts
On 2013-01-21, Steve Crawford wrote: > > Date/time is not trivial. The portions of the PostgreSQL manual dealing > with those data types bear careful and thoughtful reading and rereading > while you experiment at the same time in a psql terminal till it > "clicks." And while some time issues ar

Re: [GENERAL] Finding common hstore key=>value pairs with hstore

2013-01-27 Thread John R Pierce
On 1/27/2013 3:09 AM, Paul Norman wrote: I am in a situation where I have two tables, a and b, each with a hstore column called tags. Both tags columns have a GIN index on them. I want to find rows of a and b where the both have a particular hstore key and that key is the same. One way to do thi

[GENERAL] Finding common hstore key=>value pairs with hstore

2013-01-27 Thread Paul Norman
I am in a situation where I have two tables, a and b, each with a hstore column called tags. Both tags columns have a GIN index on them. I want to find rows of a and b where the both have a particular hstore key and that key is the same. One way to do this would be SELECT * FROM a JOIN b ON a.tags

Re: [GENERAL] Yet Another Timestamp Question: Time Defaults

2013-01-27 Thread Jasen Betts
On 2013-01-21, Gavan Schneider wrote: > On Monday, January 21, 2013 at 06:53, Adrian Klaver wrote: > > timezones I have been learning a lot from the side. > > Taking another tangent I would much prefer the default time to > be 12:00:00 for the conversion of a date to timestamp(+/-timezone).

Re: [GENERAL] Yet Another Timestamp Question: Time Defaults

2013-01-27 Thread Jasen Betts
On 2013-01-21, Rich Shepard wrote: >What is the behavior if a column data type is timestamptz but there is > only the date portion available? There must be a default time; can that be > defined? No, if you don't specify the time 00:00 (midnight) is used. if you don't specify a timezone it's l

Re: [GENERAL] Running update in chunks?

2013-01-27 Thread Jasen Betts
On 2013-01-25, Tim Uckun wrote: >> I agree that seems like the most likely cause. Each update to the >> row holding the hstore column requires adding new index entries for >> all the hstore elements, and autovacuum will need to clean up the >> old ones in the background. The best solution would be

Re: [GENERAL] Restore 1 Table from pg_dumpall?

2013-01-27 Thread Jasen Betts
On 2013-01-22, Rich Shepard wrote: >I neglected to dump a single table before adding additional rows to it via > psql. Naturally, I messed up the table. I have a full pg_dumpall of all > three databases and all their tables in a single .sql file from 2 days ago. > The file is 386M in size and

Re: [GENERAL] Cast double precision to integer & check for overflow

2013-01-27 Thread Jasen Betts
On 2013-01-26, Gavan Schneider wrote: > On Saturday, January 26, 2013 at 08:13, Ian Pilcher wrote: > >>I need to cast a double precision into an integer, and I want to check >>that the value will actually fit (modulo rounding). >> >>Coming from a C/Java background, this seems like something that s

Re: [GENERAL] noobie question

2013-01-27 Thread Scott Marlowe
On Thu, Jan 24, 2013 at 12:03 PM, Steve Clark wrote: > On 01/24/2013 01:06 PM, Chris Angelico wrote: >> >> On Fri, Jan 25, 2013 at 4:45 AM, Steve Clark wrote: >>> >>> Thanks All, >>> >>> This is for a few very small tables, less 100 records each, that a user >>> can >>> delete and insert records