Re: [GENERAL] Partitioning Advice

2012-06-06 Thread Albe Laurenz
Ben Carbery wrote: > I have a postgres server I need to move onto a new OS (RHEL6) on a new VM and > am looking for advice on > how to partition the disks to gain some performance improvement. > > In the current environment I am given a single VHDD which I have not > partitioned at all. The SAN

Re: [GENERAL] db alias

2012-06-06 Thread Albe Laurenz
Dave Gauthier wrote: > Is there a way to alias a db name for purposes of redirecting connections? For example, you have 2 > DBs, DBX and DBY. The users always connect to a DB alias called "USEDB". USEDB points to DBX today, > changed to point to DBY tomorrow, transparent to the users. That can

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Albe Laurenz
Kraus Philipp wrote: > I new on this mailing list and I need a little bit help for an idea to create different accesses to a > database with Postgres 9.1. > I'm using this PG version at the time and I have created a database with a scheme "storage". Within > this schema are some > tables, datatypes

[GENERAL] column definition for setof record functions (like dblink and crosstabs)

2012-06-06 Thread Willy-Bas Loos
Hi, Functions that return SETOF RECORD need to be called with a column definition. That is a bit limiting. For example, you might not know how many columns your crosstab will have in advance, you might not know the structure of a table that you access with dblink in advance. Also, it's always a mo

[GENERAL] postgres function for the query tree based normalization?

2012-06-06 Thread Marc Mamin
Hello, see http://postgresql.1045698.n5.nabble.com/pg-stat-statements-with-query-tr ee-based-normalization-td4989745.html Is there a plan to make this query normalization available as a postgres function. i.e.: select pg_norm_query (query text , OUT normed_query text ) best reagards, Marc

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Willy-Bas Loos
I did something like that some years ago. Albe, are rules out of grace? Philipp, here's some code: create role firm1 nologin; create role john password 'secret' login; grant firm1 to john; create role firm2 nologin; create role amy password 'secret' login; grant firm2 to amy; create table table1

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Kraus Philipp
Hi Willey, you're great :-P Am 06.06.2012 um 13:12 schrieb Willy-Bas Loos: > I did something like that some years ago. > Albe, are rules out of grace? > > create or replace rule _update as on update > to view_firm1 do instead > update table1 set val = NEW.val where id=old.id; > > create or r

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Albe Laurenz
Willy-Bas Loos wrote: > I did something like that some years ago. > Albe, are rules out of grace? Sort of, for many people: http://archives.postgresql.org/pgsql-hackers/2012-04/msg00395.php They are difficult to get right and usually not better than triggers. Ever since there were INSTEAD OF Trig

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Willy-Bas Loos
Do you mean, you want everyone to see the data, but only the "owner" can > > I would like to modify not only one field, but rather the whole record. > No problem, only don't let them change the owner > I thin NEW is the record of the view with the updated data and OLD the > orginal records (simi

Re: [GENERAL] column definition for setof record functions (like dblink and crosstabs)

2012-06-06 Thread Pavel Stehule
2012/6/6 Willy-Bas Loos : > Hi, > > Functions that return SETOF RECORD need to be called with a column > definition. That is a bit limiting. > For example, you might not know how many columns your crosstab will have in > advance, you might not know the structure of a table that you access with > db

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Philipp Kraus
Anfang der weitergeleiteten E-Mail: > Von: Willy-Bas Loos > Datum: 6. Juni 2012 13:57:45 MESZ > An: Kraus Philipp > Kopie: Albe Laurenz , pgsql-general@postgresql.org > Betreff: Re: [GENERAL] acessibility for tables > > Do you mean, you want everyone to see the data, but only the "owner" can >

[GENERAL] Problem while restoring a database from SQL_ASCII to UTF-8

2012-06-06 Thread Manoj Agarwal
Hi, I have a database in SQL_ASCII Encoding format from Postgresql-7.4.19. I have migrated to Postgresql-8.4.9 and to UTF-8 and want to restore this database in UTF-8 encoding. I am facing problem in restoring it as UTF-8. I have 29 tables in the database, out of which it is unable to restore

Re: [GENERAL] Problem while restoring a database from SQL_ASCII to UTF-8

2012-06-06 Thread Adrian Klaver
On 06/06/2012 04:30 AM, Manoj Agarwal wrote: Hi, I have a database in SQL_ASCII Encoding format from Postgresql-7.4.19. I have migrated to Postgresql-8.4.9 and to UTF-8 and want to restore this database in UTF-8 encoding. I am facing problem in restoring it as UTF-8. I have 29 tables in the data

Re: [GENERAL] Problem while restoring a database from SQL_ASCII to UTF-8

2012-06-06 Thread Peter Geoghegan
On 6 June 2012 14:12, Adrian Klaver wrote: > SQL_ASCII is not an encoding, it is basically a way of saying encoding > ignored. Given that, outside knowledge of the encoding used for data > inserted into the database is needed to make the conversion to UTF8. In > other words do you have any idea of

Re: [GENERAL] I'd like to learn a bit more about how indexes work

2012-06-06 Thread Tom Lane
Mike Christensen writes: > Thanks! One thing that still confuses me is the difference between IN > and OR. With this query: > explain analyze > select * > from foobar > where d in (500, 750); > It scans the d index only once: > 'Bitmap Heap Scan on foobar (cost=10.03..400.63 rows=196 width=1

[GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Frank Lanitz
Hi folks, I've got an issue I'm not sure I might have a misunderstanding. When calling select sum(pg_database_size(datid)) as total_size from pg_stat_database the result is much bigger than running a df -s over the postgres folder - Its about factor 5 to 10 depending on database. My understandi

Re: [GENERAL] problem after upgrade db missing

2012-06-06 Thread Alban Hertroys
On 5 June 2012 23:51, Aleksander Rozman wrote: > Like I said before all databases were missing... One of thoose database was > very important, but since I didn't have time I didn't pursue it further. If it was very important, that means that you have backups, right? >From the other replies it see

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Tom Lane
Frank Lanitz writes: > I've got an issue I'm not sure I might have a misunderstanding. When > calling > select sum(pg_database_size(datid)) as total_size from pg_stat_database > the result is much bigger than running a df -s over the postgres folder > - Its about factor 5 to 10 depending on data

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Frank Lanitz
Am 06.06.2012 17:49, schrieb Tom Lane: > Frank Lanitz writes: >> I've got an issue I'm not sure I might have a misunderstanding. When >> calling > >> select sum(pg_database_size(datid)) as total_size from pg_stat_database > >> the result is much bigger than running a df -s over the postgres fold

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Tom Lane
Frank Lanitz writes: > Am 06.06.2012 17:49, schrieb Tom Lane: >> For me, pg_database_size gives numbers that match up fairly well with >> what "du" says. I would not expect an exact match, since du probably >> knows about filesystem overhead (such as metadata) whereas >> pg_database_size does not

Re: [GENERAL] pg_basebackup blocking all queries

2012-06-06 Thread Lonni J Friedman
I'm still plagued by this. Immediately before starting a basebackup the load on my server is 1.00 or less. Within a few minutes of starting the basebackup, the load climbs steadily to 30+ and anything trying to write to the database just sits for minutes at a time, with overall performance on any

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Julien Rouhaud
On Wed, Jun 6, 2012 at 6:28 PM, Tom Lane wrote: > Frank Lanitz writes: > > Am 06.06.2012 17:49, schrieb Tom Lane: > >> For me, pg_database_size gives numbers that match up fairly well with > >> what "du" says. I would not expect an exact match, since du probably > >> knows about filesystem over

[GENERAL] Renumber table rows

2012-06-06 Thread Efraín Déctor
Hello. I have a table that his primary key is not ordered is something like this: 1 - a 12- b 123 - c etc. I want to do an update to make it like this 1 – a 2 – b 3 – c I tried this: UPDATE operador SET idoperador=(SELECT row_number() OVER (ORDER BY idoperador) from operador) But

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Alban Hertroys
On 6 Jun 2012, at 16:33, Frank Lanitz wrote: > the result is much bigger than running a df -s over the postgres folder > - Its about factor 5 to 10 depending on database. Is your du reporting sizes in Bytes or blocks or ...? Alban Hertroys -- The scale of a problem often equals the size of an

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Guillaume Lelarge
On Wed, 2012-06-06 at 18:46 +0200, Julien Rouhaud wrote: > On Wed, Jun 6, 2012 at 6:28 PM, Tom Lane wrote: > > > Frank Lanitz writes: > > > Am 06.06.2012 17:49, schrieb Tom Lane: > > >> For me, pg_database_size gives numbers that match up fairly well with > > >> what "du" says. I would not expe

[GENERAL] Query runtime dependent on ANALYZE run

2012-06-06 Thread Viktor Rosenfeld
Hi, (I've sent a copy of this message to pgus-general in error. Sorry about that.) I've noticed that the selection of the executed query plan (and therefore query runtime) is dependent on the statistics generated by an ANALYZE run. As an demonstration, I chose the best runtime of 5 consecutive ru

Re: [GENERAL] pg_database_size differs from df -s

2012-06-06 Thread Frank Lanitz
On Wed, 6 Jun 2012 20:31:36 +0200 Alban Hertroys wrote: > On 6 Jun 2012, at 16:33, Frank Lanitz wrote: > > > the result is much bigger than running a df -s over the postgres > > folder > > - Its about factor 5 to 10 depending on database. > > > Is your du reporting sizes in Bytes or blocks or

Re: [GENERAL] Renumber table rows

2012-06-06 Thread David Johnston
Try something along the lines of: UPDATE operador SET idoperador = new_idoperador FROM ( SELECT idoperador AS old_idoperador, ROW_NUMBER() OVER (ORDER BY idoperador) AS new_idoperador FROM operador ) lookup WHERE operador.idoperador = lookup.old_idoperad

[GENERAL] How to get user privs on a table using select

2012-06-06 Thread Gauthier, Dave
Hi: Inside a perl/dbi script, I want to determine which privs (select, insert, update, delete, ...) user 'foo' has on table 'footable'. There must be metadata tables or a view that has this.

Re: [GENERAL] Renumber table rows

2012-06-06 Thread Efraín Déctor
Thank you. It really worked. From: David Johnston Sent: Wednesday, June 06, 2012 3:17 PM To: 'Efraín Déctor' ; pgsql-general@postgresql.org Subject: RE: [GENERAL] Renumber table rows Try something along the lines of: UPDATE operador SET idoperador = new_idoperador FROM (

Re: [GENERAL] How to get user privs on a table using select

2012-06-06 Thread Josh Kupershmidt
On Wed, Jun 6, 2012 at 1:41 PM, Gauthier, Dave wrote: > Inside a perl/dbi script, I want to determine which privs (select, insert, > update, delete, ...) user 'foo' has on table 'footable'.   There must be > metadata tables or a view that has this. Try: psql -E dbname \z tablename And look a

[GENERAL] Need help in transferring FP to Int64 DateTime

2012-06-06 Thread Benson Jin
Hi All, I am sure this question has been asked before, however, I failed to find any related topics in the internet. We have a database about 100GB in size. It was started back in 7.x days and has been upgraded along the way to 9.0. Because of the historical reason, all timestamps are stored i

Re: [GENERAL] Need help in transferring FP to Int64 DateTime

2012-06-06 Thread Josh Kupershmidt
On Wed, Jun 6, 2012 at 9:20 AM, Benson Jin wrote: > I am sure this question has been asked before, however, I failed to find any > related topics in the internet. We have a database about 100GB in size. It > was started back in 7.x days and has been upgraded along the way to 9.0. > Because of the

Re: [GENERAL] acessibility for tables

2012-06-06 Thread Philipp Kraus
Hello, On 2012-06-06 09:24:16 +0200, Albe Laurenz said: You can define INSTEAD OF triggers on a view so that you can insert, update and delete on it. The trigger performs an operation on the base table instead. I have created the trigger with "insead of". If I try to insert a row into the vi

Re: [GENERAL] Need help in transferring FP to Int64 DateTime

2012-06-06 Thread Adrian Klaver
On 06/06/2012 09:20 AM, Benson Jin wrote: Hi All, I am sure this question has been asked before, however, I failed to find any related topics in the internet. We have a database about 100GB in size. It was started back in 7.x days and has been upgraded along the way to 9.0. Because of the histor

[GENERAL] Counting # of consecutive rows with specified value(s)?

2012-06-06 Thread Ken Tanzer
I'm working with an attendance table, where each person gets a record for each day of class, with an attendance code (ABSENT, ATTENDED, ...). I'm trying to figure out how to get the number of consecutive absences a person has. I'm guessing this can be done without writing a function, but I need s

Re: [GENERAL] Counting # of consecutive rows with specified value(s)?

2012-06-06 Thread David Johnston
On Jun 6, 2012, at 22:20, Ken Tanzer wrote: > I'm working with an attendance table, where each person gets a record for > each day of class, with an attendance code (ABSENT, ATTENDED, ...). I'm > trying to figure out how to get the number of consecutive absences a person > has. I'm guessing