[GENERAL] maximum amount of data to be written during checkpoint?

2008-01-24 Thread hubert depesz lubaczewski
hi, what is the maximum amount of data to be written in checkpoint? i always assumed this to be . but some last tests show it to be much more. what am i missing? best regards, depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http

Re: [GENERAL] LIKE and REGEX optimization

2008-01-17 Thread hubert depesz lubaczewski
On Tue, Jan 15, 2008 at 04:49:41PM -0600, Scott Marlowe wrote: > This query is not capable of using an index on name, since you can't > use an index with a like beginning with a %... So actually you can. you just can't use index for like %something%, but it can be solved using trigrams or another

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread hubert depesz lubaczewski
On Wed, Nov 14, 2007 at 10:26:52AM -0500, Tom Lane wrote: > That's a fairly ugly/messy way of doing it. If you're going to need a C > function anyway, why not just do it directly? As in the attachment. actually you dont have to do it in c. alec pointed (in comments) that there already is stateme

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 03:11:50PM -0800, Sarah Dougherty wrote: > To recap with an example, the query below works fine, but how do I add a > series to it? generate_series will not help with this. try the sequence approach, or this: http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulat

Re: [GENERAL] Regression in 8.3?

2007-11-12 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 05:18:28PM -0500, Tom Lane wrote: > regression=# select '00123'::text like '0%'; > ?column? > -- > t > (1 row) > regression=# select '00123'::int4 like '0%'; > ?column? > -- > f > (1 row) i think it's definitelly ok - '00123'::text is *not equal* to '0

Re: [GENERAL] reverse strpos?

2007-11-12 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 10:54:53AM -0500, Gauthier, Dave wrote: > Is there a function that'll return the position of the last occurance of > a char in a string? > For Example, in the string 'abc/def/ghi' I want the position of the 2nd > '/'. # select length(substring('abc/def/ghi' from '^(.*/)'

Re: [GENERAL] Regression in 8.3?

2007-11-12 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 11:26:09AM -0500, Tom Lane wrote: > hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > > on the other hand. while i know and understand why there can't be "=" > > operator for text and int, i think that "like" could be

Re: [GENERAL] Regression in 8.3?

2007-11-12 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 02:19:21PM +0100, Patric Bechtel wrote: > Just guess: We have bigint id's through the system, so I want to give > the users the convenience of typing only the last 4-5 digits (which most > of the time is enough). So the query we issue really is > ... like "%$userinput" > Mak

[GENERAL] plperl and regexps with accented characters - incompatible?

2007-11-10 Thread hubert depesz lubaczewski
hi, i wrote this function: #v+ CREATE OR REPLACE FUNCTION test(TEXT) RETURNS bool language plperl as $$ return (shift =~ /[a-ząćęłńóśźżĄĆĘŁŃŚÓŹŻ0-9_-]+/i) || 0; $$; #v- it's functioning it not really relevant. important thing is, that the creation of it fails: psql:z.sql:25: ERROR: creation of P

Re: [GENERAL] why there is no interval / interval operator?

2007-11-08 Thread hubert depesz lubaczewski
On Thu, Nov 08, 2007 at 10:50:39AM -0500, Tom Lane wrote: > hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > > we have interval / float8 ( = interval), so i think that adding interval > > / interval ( = float8) should be possible. > What would you define it to mean,

[GENERAL] why there is no interval / interval operator?

2007-11-08 Thread hubert depesz lubaczewski
is it just a simple ommission, or am i missing something? we have interval / float8 ( = interval), so i think that adding interval / interval ( = float8) should be possible. depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://w

Re: [GENERAL] Questions concerning check constraints

2007-11-02 Thread hubert depesz lubaczewski
On Fri, Nov 02, 2007 at 10:04:06AM +0100, Christian Rengstl wrote: > 1) Is it possible to refer to a column in a different table, ie > entering a value in mytable.x should only be allowed if mytable2.y=1 for > example? I know that it is possible to use triggers to do that, but I > think adding a si

Re: [GENERAL] getting list of tables from command line

2007-11-02 Thread hubert depesz lubaczewski
On Thu, Nov 01, 2007 at 08:03:08PM -0700, Craig White wrote: > *** begin pg_table_dump.scr *** > #/bin/sh > # > # Script to identify tables, backup schema and data separately and > # then finally, vacuum each table > # > DB_NAME=MY_DB > BACKUP_PATH=/home/backup/postgres/production > MY_SCHEMA=publi

Re: [GENERAL] getting list of tables from command line

2007-11-01 Thread hubert depesz lubaczewski
On Wed, Oct 31, 2007 at 08:01:41AM -0700, Craig White wrote: > my script looks like this... > (all I want is to get a list of the tables into a text file pg_tables) everybody else showed some ways, but i'll ask a question: i hope you're not treating it as a backup? bacause when you do it that way

Re: [GENERAL] improvement proposition

2007-10-16 Thread hubert depesz lubaczewski
On Tue, Oct 16, 2007 at 11:16:46AM -0400, Tom Lane wrote: > Turn on log_statement. I don't believe the feature you are asking for > will be nearly as useful as you think. More than likely, what it > will show you is something like "commit; begin" and you'll be little > wiser than before. What yo

[GENERAL] improvement proposition

2007-10-16 Thread hubert depesz lubaczewski
hi, would it be possible for someone to add "last query" for pg_stat_activity view? there is a lot of cases that we have "idle in transaction" sitting for long time, and since we dont log all queries it is next to impossible to tell where in app code the problem lies. it would be very useful to g

Re: [GENERAL] Easier string concat in PL funcs?

2007-10-03 Thread hubert depesz lubaczewski
On Wed, Oct 03, 2007 at 11:47:26AM -0400, Jerry Sievers wrote: > Question: Am I overlooking a simple way of doing this? yes. use plpython or plperl to do the job. depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.depesz.c

Re: [GENERAL] Find min year and min value

2007-10-02 Thread hubert depesz lubaczewski
On Tue, Oct 02, 2007 at 04:29:02PM +0200, Stefan Schwarzer wrote: > If I want to find the "common smallest year" for two given variables > (say, I have years 1970, 1971, 2005 for variable 1 (GDP) and > 1980, 1981,... 2003) for variable 2 (Fish Catch) ). It should come up > with 1980 for a

[GENERAL] 8.3devel, csvlog, missing info?

2007-09-26 Thread hubert depesz lubaczewski
hi, i just fetched newest 8.3 from cvs head, compiled, ran. when i set logs to "stderr", and enter query with error, i get this information in logs: ERROR: subquery in FROM must have an alias HINT: For example, FROM (SELECT ...) [AS] foo. STATEMENT: select count(*) from (select x from q order by

[GENERAL] lowering impact of checkpoints

2007-09-25 Thread hubert depesz lubaczewski
hi, our system is handling between 600 and 2000 transactions per second. all of them are very small, very fast. typical query runs in under 1ms. yes - sometimes we get queries that take longer than then should get. simple check shows that we have a very visible pattern of every-5-minutes peak. in t

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
On Sat, Sep 15, 2007 at 11:48:19AM -0400, Tom Lane wrote: > As of a couple years ago, the regular text = operator only yields true > for bitwise-equal strings, so we could perhaps drop ~=~ and use = in its > place. But I'd be worried about breaking existing queries that expect > the strangely-name

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
On Sat, Sep 15, 2007 at 11:09:39AM -0400, Tom Lane wrote: > hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > > index is created using text_pattern_ops so i will be able to use it in > > 'where word like '...%'' > > but, it appears it is no

[GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
i have this table: # \d text_words Table "public.text_words" Column | Type |Modifiers +-+- id | integer | not null default nextval('text_words_id_seq'::regclass) word

Re: [GENERAL] Locking entire database

2007-09-15 Thread hubert depesz lubaczewski
On Fri, Sep 14, 2007 at 04:48:08PM +0300, Panagiotis Pediaditis wrote: > Is there some way of locking all database tables in a transaction > without knowing their names > or even better just locking the entire database? I know this is bad > tactics but there is a specific > case where i need it.

Re: [GENERAL] UPDATE pg_catalog.pg_class as NO Superuser??

2007-09-13 Thread hubert depesz lubaczewski
On Thu, Sep 13, 2007 at 01:06:11PM +0200, Kai Behncke wrote: > Could you give me an example for that please? > Thank you very much :-), Kai i think i gave. ok. again: alter table some_table disable trigger all; depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly

Re: [GENERAL] UPDATE pg_catalog.pg_class as NO Superuser??

2007-09-13 Thread hubert depesz lubaczewski
On Thu, Sep 13, 2007 at 11:25:39AM +0200, Kai Behncke wrote: > I want that the user xy (who is no superuser) can Update a systemtable with: > UPDATE pg_catalog.pg_class SET reltriggers = 0; why dont you simply alter table disable trigger? depesz -- quicksil1er: "postgres is excellent, but like

Re: [GENERAL] get a list of table modifications in a day?

2007-09-13 Thread hubert depesz lubaczewski
On Thu, Sep 13, 2007 at 09:59:30AM +0200, Ottavio Campana wrote: > 1) pg_dump each day and run diff it will become increasingly painful as the table size increases. > 2) modify some triggers we use and store the information in another table this is the best choice. you can use table_log extensio

Re: [GENERAL] ON UPDATE trigger question

2007-09-13 Thread hubert depesz lubaczewski
On Wed, Sep 12, 2007 at 01:56:13PM -0500, Josh Trutwin wrote: > Or would you have to compare each field in OLD, NEW to see if > anything actually changed? you dont have to compare all columns (at least not in 8.2 and newer). please take a look at http://www.depesz.com/index.php/2007/09/08/avoiding

Re: [GENERAL] Sthange things happen: SkyTools pgbouncer is NOT a balancer

2007-09-11 Thread hubert depesz lubaczewski
On Tue, Sep 11, 2007 at 08:02:34PM +0400, Dmitry Koterov wrote: > So, it's completely magical for me why "Session pooling", "Transaction > pooling" and "Statement pooling" options are exist (see > https://developer.skype.com/SkypeGarage/DbProjects/PgBouncer). If pgbouncer > is not a balancer, what

Re: [GENERAL] Alternative to drop index, load data, recreate index?

2007-09-11 Thread hubert depesz lubaczewski
On Mon, Sep 10, 2007 at 05:06:35PM -0700, Jason L. Buberel wrote: > I am considering moving to date-based partitioned tables (each table = > one month-year of data, for example). Before I go that far - is there > any other tricks I can or should be using to speed up my bulk data loading? did you

Re: [GENERAL] Tutorial EXPLAIN for idiots?

2007-09-07 Thread hubert depesz lubaczewski
On Fri, Sep 07, 2007 at 12:30:06PM +0200, Erwin Moller wrote: > Any tips/sites? check this: http://www.postgresql.org/communityfiles/13.sxi depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.depesz.com/ - blog dla ciebie

Re: [GENERAL] Need suggestion on how best to update 3 million rows

2007-09-06 Thread hubert depesz lubaczewski
On Thu, Sep 06, 2007 at 01:39:51PM +0200, Nis Jørgensen wrote: > Rubbish. From the documentation: hmm .. i'm sorry - i was *sure* about it because we were bitten by something like this lately - apparently it was similiar but not the same. sorry again for misinformation. depesz -- quicksil1er:

Re: [GENERAL] Need suggestion on how best to update 3 million rows

2007-09-06 Thread hubert depesz lubaczewski
On Thu, Sep 06, 2007 at 11:08:02AM +0200, Alban Hertroys wrote: > create index tmp_idx on table(number) where number != trim(number); > analyze table; > update table set number = trim(number) where number != trim(number); dont use !=. use <>. != does something different, and in fact it is not a re

Re: [GENERAL] SQL query with IFs (?) to "Eliminate" NULL Values

2007-09-05 Thread hubert depesz lubaczewski
On Wed, Sep 05, 2007 at 11:15:43AM +0200, Stefan Schwarzer wrote: > SELECT DISTINCT (tpes_total.y_2004 / pop_total.y_2004) AS > y_2004, countries_view.name AS name > FROM pop_total, countries_view > LEFT JOIN tpes_total ON tpes_total.id = countries_view.id > WHERE pop_total.y_2004

Re: [GENERAL] "out of memory" error

2007-08-22 Thread hubert depesz lubaczewski
On Wed, Aug 22, 2007 at 07:07:20PM +0200, Christian Schröder wrote: > These are the current settings from the server configuration: >shared_buffers = 3GB this is *way* to much. i would suggest lowering it to 1gig *at most*. >max memory size (kbytes, -m) 3441565 this looks like to

Re: [GENERAL] Using oid as pkey

2007-08-21 Thread hubert depesz lubaczewski
On Mon, Aug 20, 2007 at 07:00:32PM -0500, D. Dante Lorenso wrote: > Exactly what I was looking for. Looks like I need to make moves to get > from 8.1 onto 8.2 ;-) in any pg you should simply use select currval('sequence_name'); and be happy with it. depesz -- quicksil1er: "postgres is excelle

Re: [GENERAL] Some frustrations with admin tasks on PGSQL database

2007-08-17 Thread hubert depesz lubaczewski
On Fri, Aug 17, 2007 at 10:22:55PM +0800, Phoenix Kiula wrote: > Wow, smartest advice of the day! Yes, a lot of our data in that column > has dots and numbers (800,000 compared to 6 million), so I wanted to > get only to the stuff that was pure alphabets, but just didn't think > of how. what i rea

Re: [GENERAL] Some frustrations with admin tasks on PGSQL database

2007-08-17 Thread hubert depesz lubaczewski
On Fri, Aug 17, 2007 at 09:50:42PM +0800, Phoenix Kiula wrote: > > How big is the actual table itself (in bytes). > Where should I find this? select pg_relation_size('mytable'); depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http

Re: [GENERAL] Some frustrations with admin tasks on PGSQL database

2007-08-17 Thread hubert depesz lubaczewski
On Fri, Aug 17, 2007 at 07:49:08PM +0800, Phoenix Kiula wrote: > I have dropped all indexes/indicises on my table, except for the > primary key. Still, when I run the query: > UPDATE mytable SET mycolumn = lower(mycolumn); can you please check this: select count(*) from mytable; select count(

Re: [GENERAL] how to get id of currently executed query?

2007-08-16 Thread hubert depesz lubaczewski
On Thu, Aug 16, 2007 at 11:20:30AM -0400, Tom Lane wrote: > AFAIR, the only state that's guaranteed to work like that is > statement_timestamp. Of course you have to worry whether your machine > is fast enough to do more than one client interaction within whatever > the clock resolution is. i'll

Re: [GENERAL] how to get id of currently executed query?

2007-08-16 Thread hubert depesz lubaczewski
On Thu, Aug 16, 2007 at 09:14:24AM -0500, Decibel! wrote: > Well of course, if you're running it in a separate command. If you run > the function twice from one query I'd expect both to return the same. no. if i run one query with function i get sifferend commandid's inside the function. example:

[GENERAL] how to get id of currently executed query?

2007-08-16 Thread hubert depesz lubaczewski
hi, i need something to distinguish two separate calls for some select. i tried to use c functions GetCurrentTransactionId() and GetCurrentCommandId(), but there is a problem: if i'll make plpgsql function, which uses GetCurrentTransactionId() and GetCurrentCommandId() - getCurrentCommandId change

Re: [GENERAL] UDFs

2007-08-13 Thread hubert depesz lubaczewski
On Mon, Aug 13, 2007 at 07:36:41PM +, jf wrote: > > usually it's in: /share/postgresql/contrib/pgcrypto.sql > > in the database you want to use pgcrypto functions, you simply run this > > sql (as superuser), and that's all. > theory# pwd > /home/jf/postgresql-8.2.4 > theory# cd share > bash: cd

Re: [GENERAL] UDFs

2007-08-13 Thread hubert depesz lubaczewski
On Mon, Aug 13, 2007 at 07:22:26PM +, jf wrote: > understood, I appreciate the suggestion. In addition I couldn't find any > documentation that told me how to install the functions in pgcrypto (do I > need to CREATE FUNCTION for every function in there?), the README mentions > a .sql file thats

Re: [GENERAL] UDFs

2007-08-13 Thread hubert depesz lubaczewski
On Mon, Aug 13, 2007 at 05:07:50PM +, jf wrote: > my understanding was that pgcrypto was not compiled by default? your function is also not compiled on default. but pgcrypto is at the very least available by default (in sources, or in precompiled packages). > Furthermore, finding next to no d

Re: [GENERAL] UDFs

2007-08-13 Thread hubert depesz lubaczewski
On Mon, Aug 13, 2007 at 03:17:36PM +, jf wrote: > Trying to implement some simple digest routines via UDFs and for whatever > reason I get: ERROR: invalid memory alloc request size 4294967293 on > PG_RETURN_TEXT_P(); any ideas what the issue is exactly? just checking - you do realize that it'

Re: [GENERAL] TimestampTZ

2007-08-12 Thread hubert depesz lubaczewski
On Mon, Aug 13, 2007 at 02:47:06PM +1000, Naz Gassiep wrote: > When entering data into a timestamptz field, if no timezone is added > does it assume you've entered a UTC time, or the time at the timezone > set in the session with SET TIMEZONE, or the local system time ? i dont understand - why d

Re: [GENERAL] [SQL] Using function like where clause

2007-08-10 Thread hubert depesz lubaczewski
On Mon, Aug 06, 2007 at 04:44:29PM -0300, Ranieri Mazili wrote: > 1) Can I use a function that will return a string in a where clause like > bellow? > 2) Can I use a function that will return a string to return the list of > columns that I want to show like below? not in sql. you can in pl/pgsql

Re: [GENERAL] plpgsql equivalent to plperl $_SHARED and plpythonu global dictionary GD?

2007-07-10 Thread hubert depesz lubaczewski
On 7/9/07, Zlatko Matic <[EMAIL PROTECTED]> wrote: Does plpgsql has something equivalent to plperl $_SHARED or plpythonu global dictionary GD? no, but you can use some table to emulate this. or a temp table. depesz -- http://www.depesz.com/ - nowy, lepszy depesz

Re: [GENERAL] tsearch2 questions

2007-07-04 Thread hubert depesz lubaczewski
On 7/4/07, Joshua N Pritikin <[EMAIL PROTECTED]> wrote: From where are you quoting? I was quoting from: http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/tsearch2-ref.html i was quoting file http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/tsearch-V2-intro.html or actual

Re: [GENERAL] Date for a week day of a month

2007-07-04 Thread hubert depesz lubaczewski
On 7/3/07, Emi Lu <[EMAIL PROTECTED]> wrote: Can I know how to get the date of each month's last Thursday please? Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 you can easily do it without functions. for example, this select: SELECT cast(d.date + i

Re: [GENERAL] tsearch2 questions

2007-07-04 Thread hubert depesz lubaczewski
On 7/4/07, Joshua N Pritikin <[EMAIL PROTECTED]> wrote: Please mention that in the documentation: dont you think this is perfeclty clear? "If you want to do something specific with columns, you may write your very own trigger function using plpgsql or other procedural languages (but not SQL,

Re: [GENERAL] data partitions across different nodes

2007-06-26 Thread hubert depesz lubaczewski
On 6/26/07, 金星星 <[EMAIL PROTECTED]> wrote: Are there any solutions based on PostgreSQL that can support distributing partitions (horizontal fragmentations) across different nodes. It doesn't need to support distributed transaction, since data inconsistent is not a critical problem in my situatio

Re: [GENERAL] a JOIN on same table, but 'slided over'

2007-06-26 Thread hubert depesz lubaczewski
On 6/26/07, Rafal Pietrak <[EMAIL PROTECTED]> wrote: Is there an SQL construct to get it? select distinct on (t1.id) t1.*, t2.* from test t1 join test t2 on t2.id > t1.id order by t1.id asc, t2.id asc should do the trick. depesz -- http://www.depesz.com/ - nowy, lepszy depesz

Re: [GENERAL] strange change (and error) in 8.3 ?

2007-06-14 Thread hubert depesz lubaczewski
On 6/14/07, Tom Lane <[EMAIL PROTECTED]> wrote: This is intentional --- implicit casts to text are gone. You should be happy that the above now fails, because it's calling your attention to the fact that you've got very ill-defined semantics there. Is the thanks for clarification. actually

[GENERAL] strange change (and error) in 8.3 ?

2007-06-14 Thread hubert depesz lubaczewski
hi, this query: select 1 where '1'::text in (1::int8); worked fine in 8.2: # select version(); version PostgreSQL 8.2.4 on i686-pc-linux-gnu, compiled by GCC

Re: [GENERAL] track ddl changes on single database

2007-06-11 Thread hubert depesz lubaczewski
you can modify log_line_prefix to contain database name. depesz On 6/11/07, Rikard Pavelic <[EMAIL PROTECTED]> wrote: Hi! I'm looking for recommendation for tracking DDL changes on single database instance. Currently I'm using pg_log to extract DDL changes, but those changes are cluster wide

Re: [GENERAL] insane index scan times

2007-06-09 Thread hubert depesz lubaczewski
On 6/7/07, Sergei Shelukhin <[EMAIL PROTECTED]> wrote: Version is 8.1 The query I originally ran returned ~4-5 rows and had a lot of other joins and filtering conditions prior to the join with the big table. Is there any way to instruct postgres to do joins in the specific order or smth? make

Re: [GENERAL] Strange delimiters problem

2007-06-03 Thread hubert depesz lubaczewski
On 6/3/07, Andrej Kastrin <[EMAIL PROTECTED]> wrote: ||001||,||Classification||,||Economics||,||N|| ||001||,||Classification||,||Trends||,||Y|| etc... it looks like you should be able to read it using COPY command. something like: copy some_table from stdin with delimiter ',' csv quote '||';

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Martijn van Oosterhout wrote: In an AFTER trigger you can be sure you're seeing what actually got inserted. In a BEFORE trigger other triggers after you could still modify the data... yes but in after trigger the only thing you can do is to raise exception. you cannot fix the data,

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Jeff Davis <[EMAIL PROTECTED]> wrote: You can use an AFTER trigger instead of a CHECK constraint (but that may have a performance impact - test for your application). are you sure you meant AFTER? why? generally data-checks should be in before triggers. i guess. depesz -- http://w

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: > write a triggers which do that. I understand that a trigger should be written, and I have already implemented two such triggers, as described above. no, i think i didn't make myself clear. let's use this situation: we have tables: create ta

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: But, really, I just want to be able to test to see how many references there are to a key. Is there some way to do that? write a triggers which do that. depesz -- http://www.depesz.com/ - nowy, lepszy depesz ---(en

Re: [GENERAL] Practical question.

2007-03-17 Thread hubert depesz lubaczewski
On 3/17/07, louis gonzales <[EMAIL PROTECTED]> wrote: Statement-level triggers follow simple visibility rules: none of the changes made by a statement are visible to statement-level triggers that are invoked before the statement, whereas all modifications are visible to statement-level after trig

Re: [GENERAL] Creation of a read-only role.

2007-03-17 Thread hubert depesz lubaczewski
On 3/16/07, Dmitry Koterov <[EMAIL PROTECTED]> wrote: Overall, we need 3 roles: 1. Administrator: can do anything with a database (by default this user is already exists - "postgres"). 2. Read-only: can only read. Runs on all slave nodes. actually - you dont need the read-only role, if this is

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread hubert depesz lubaczewski
On 3/16/07, Jasbinder Singh Bali <[EMAIL PROTECTED]> wrote: just wondeng why doesn't it let me put my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", "", ""); in eval you dont need to put ->connect in eval. just set connect option 'raiseerror' to 0 (and printerror as

Re: [GENERAL] Practical question.

2007-03-16 Thread hubert depesz lubaczewski
On 3/16/07, louis gonzales <[EMAIL PROTECTED]> wrote: I want to write a statement-level trigger - one that happens once per statement - such that, immediately after an insert into a table(which gets a unique integer value as an ID from a defined sequence, being the primary key on the table), a ne

Re: [GENERAL] Statement logging

2007-03-14 Thread hubert depesz lubaczewski
On 3/14/07, A. Kretschmer <[EMAIL PROTECTED]> wrote: Not necessary, you can set it via session without reload or restart. but then it will work only for the connection that did set it. and i understood that hannes wanted to profile working application - so it's not really useful. depesz -- ht

Re: [GENERAL] Statement logging

2007-03-14 Thread hubert depesz lubaczewski
On 3/14/07, Hannes Dorbath <[EMAIL PROTECTED]> wrote: Is there any way to enable statement logging at runtime without a restart? If not I think that would be a nice feature, as one sometimes need to debug applications that are already in production.. change log_min_duration_statement and do pg_

Re: [GENERAL] real multi-master replication?

2007-03-05 Thread hubert depesz lubaczewski
On 3/5/07, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > but i dont insist on async. if there is multi-master replication for > postgresql it would be great if it would be sync. I don't know it this is what you are looking for, but this new link on the postgresql home page suggests that a new

Re: [GENERAL] real multi-master replication?

2007-03-05 Thread hubert depesz lubaczewski
On 3/5/07, Steve Atkins <[EMAIL PROTECTED]> wrote: I don't believe there is, or can be, any asynchronous multi-master replication system for any database that will work with all possible general purpose constructs. but i dont insist on async. if there is multi-master replication for postgresql

Re: [GENERAL] usage for 'with recursive'?

2007-03-05 Thread hubert depesz lubaczewski
On 3/2/07, Kenneth Downs <[EMAIL PROTECTED]> wrote: This reminds me of another advantage of the WITH RECURSIVE, which is that it pushes to overhead to SELECT, with no associated write-time overheads. hmm .. why do you consider this as advantage? i would say it's rather drawback. depesz --

Re: [GENERAL] real multi-master replication?

2007-03-05 Thread hubert depesz lubaczewski
On 3/4/07, Devrim GÜNDÜZ <[EMAIL PROTECTED]> wrote: PGCluster may be the thing that you are looking for. However, if you are looking at something that is similar to Oracle's RAC, it is the PGCluster-II that you are looking for, which is under heavy development right now. i dont know oracle. but

Re: [GENERAL] real multi-master replication?

2007-03-05 Thread hubert depesz lubaczewski
On 3/4/07, Bill Moran <[EMAIL PROTECTED]> wrote: How would you define multi-master? i am able to write to any machine in cluster, and read from any. hopefully - wiithout any kind of "single point of failure" (like pgpool connection point). depesz ---(end of broadcast)-

[GENERAL] real multi-master replication?

2007-03-04 Thread hubert depesz lubaczewski
hi, i read about some replication system for postgresql, but - as far as i know there is none real multi-master replication system for postgresql. all i have seen are based on "query replication" with various "hacks" for specific constructions (like now()). my question is - is there any (even full

Re: [GENERAL] usage for 'with recursive'?

2007-03-02 Thread hubert depesz lubaczewski
On 3/1/07, Kenneth Downs <[EMAIL PROTECTED]> wrote: Better? I think perhaps different. There is materialized path, which requires a very problematic unlimited-length column to hold the path, and there is upper/lower bounds, which again requires client-side row-by-row processing. Both have the

[GENERAL] usage for 'with recursive'?

2007-03-01 Thread hubert depesz lubaczewski
there have been a discussions about how posdtgresql needs 'with recursive' queries. not that i would like to object the idea (new feature is always a good thing), but is anybody able to show me real usage of this kind of queries? as i see it the only usage for 'with recursive' is when one have a

Re: [GENERAL] Odd behaviour of timestamptz

2007-02-21 Thread hubert depesz lubaczewski
On 2/21/07, Tom Lane <[EMAIL PROTECTED]> wrote: I'll bet you are running in Europe/Amsterdam time zone? The above is what about me? i'm in poland, and runing in europe/warsaw time zone. i assume we also had some issues lie this - where can i read about it? best regards, depesz -- http://w

Re: [GENERAL] Odd behaviour of timestamptz

2007-02-21 Thread hubert depesz lubaczewski
On 2/21/07, Michael Glaesemann <[EMAIL PROTECTED]> wrote: I suspect your RPMs build PostgreSQL without --enable-integer- datetimes. Without this configure flag, timestamps are represented as floats, with all of the imprecision that implies. See the second note below the Date/Time Types table:

Re: [GENERAL] Adjacency List or Nested Sets to model file system hierarchy?

2007-02-13 Thread hubert depesz lubaczewski
On 2/12/07, Bill Moseley <[EMAIL PROTECTED]> wrote: Also, the Nested Sets seem to solve problems I don't have -- such as finding all descendants of a given node. you can also check different way. i described it here: http://www.depesz.com/various/various-sqltrees-implementation.php it is in p

[GENERAL] date of table creation

2007-01-10 Thread hubert depesz lubaczewski
hi, is there any way to tell when particular table has been created? i don't see such info in pg_class, but maybe i'm missing something. if there is no such way - would there be any chance that somebody proficient with c would write a patch adding this? best regards, depesz -- http://www.depes

Re: [GENERAL] "no unpinned buffers available" ? why? (hstore and plperl involved)

2007-01-04 Thread hubert depesz lubaczewski
On 1/3/07, Richard Huxton wrote: hubert depesz lubaczewski wrote: > On 1/3/07, Richard Huxton wrote: >> >> If you do that separately at the start of the process, (one query per >> custom column in the old table) then it becomes straightforward. >> > >

Re: [GENERAL] "no unpinned buffers available" ? why? (hstore and plperl involved)

2007-01-03 Thread hubert depesz lubaczewski
On 1/3/07, Tom Lane <[EMAIL PROTECTED]> wrote: Could you reduce this to a self-contained example please? Your functions depend on a bunch of tables that you have not provided definitions or data for ... i'll try. it will take some time though. hubert -- http://www.depesz.com/ - nowy, lepsz

Re: [GENERAL] "no unpinned buffers available" ? why? (hstore and plperl involved)

2007-01-03 Thread hubert depesz lubaczewski
On 1/3/07, Richard Huxton wrote: If you do that separately at the start of the process, (one query per custom column in the old table) then it becomes straightforward. no, because meaning of "col1" in advert_custom_fields is different for each record. for one record it's codename might be "e

Re: [GENERAL] "no unpinned buffers available" ? why? (hstore and plperl involved)

2007-01-03 Thread hubert depesz lubaczewski
On 1/3/07, Richard Huxton wrote: > my questions are: > 1. is it a bug and will it be fixed? > 2. if it is a bug - is it in hstore? plperl? my code? My guess would be that plperl isn't freeing it's result set storage until the end of the transaction. Might not be classed as a bug, but certainly

[GENERAL] "no unpinned buffers available" ? why? (hstore and plperl involved)

2007-01-03 Thread hubert depesz lubaczewski
hi, i got this situation: i'm using 8.3devel checked out from cvs about a week ago. if this is neccesary i can rerun the tests in 8.2 or something else. i wrote this code: CREATE TYPE srf_get_old_cf_for_advert AS ( codename TEXT, value TEXT ); CREATE OR REPLACE FUNCTION get_old_cf_for_adver

Re: [GENERAL] out of memory woes

2006-12-19 Thread hubert depesz lubaczewski
On 19 Dec 2006 07:01:41 -0800, Angva <[EMAIL PROTECTED]> wrote: shared_buffers = 57344 work_mem = 20 maintenance_work_mem = 524288 work_mem seems to be high. what is you max_connections setting? depesz -- http://www.depesz.com/ - nowy, lepszy depesz

Re: [GENERAL] out of memory woes

2006-12-18 Thread hubert depesz lubaczewski
On 18 Dec 2006 07:16:56 -0800, Angva <[EMAIL PROTECTED]> wrote: The funny thing is that once it does fail, it fails consistently until the server is bounced - I must have run the cluster script 10 times after the initial failure. The server's 6g of RAM is normally more than enough (so normally,

Re: [GENERAL] select query not using index

2006-12-02 Thread hubert depesz lubaczewski
On 12/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: The index was created before the table was populated. There are 3 rows in the table for 3 different users. Now when I do a postgresql will not use index scan for table with 3 rows in it. it is way faster to use seq scan on it. depesz

Re: [GENERAL] postgresql 8.2 rc1 - crash

2006-12-02 Thread hubert depesz lubaczewski
On 11/30/06, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: On 11/30/06, Teodor Sigaev <[EMAIL PROTECTED]> wrote: > > Fixed, thank you. Changes are commited in CVS, pls, try it (I think that > index > is corrupted, so you need to recreate it) great. thanks. i wil

Re: [GENERAL] postgresql 8.2 rc1 - crash

2006-11-30 Thread hubert depesz lubaczewski
On 11/30/06, Teodor Sigaev <[EMAIL PROTECTED]> wrote: Fixed, thank you. Changes are commited in CVS, pls, try it (I think that index is corrupted, so you need to recreate it) great. thanks. i will retry. full retry will take some time - i can estimate that i will be able to reply tomorrow in

Re: [GENERAL] postgresql 8.2 rc1 - crash

2006-11-30 Thread hubert depesz lubaczewski
On 11/30/06, Teodor Sigaev <[EMAIL PROTECTED]> wrote: gdb /usr/local/pgsql/bin/postgres your_core_file If it's needed, change path to postgres file. In gdb, type # bt and send output sure, here you have: $ gdb /home/pgdba/work/bin/postgres /home/pgdba/data/core GNU gdb 6.3-debian Copyright 20

[GENERAL] postgresql 8.2 rc1 - crash

2006-11-30 Thread hubert depesz lubaczewski
hi, i have been testing 8.2 rc1, while i got this problem. base data: linux, 32bit, kernel: 2.6.18.3; debian postgresql version: PostgreSQL 8.2rc1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5(Debian 1: 3.3.5-13) problematic table is over 2gigabytes in size, and has several indices - one

Re: [GENERAL] Scaleable DB structure for counters...

2006-07-16 Thread hubert depesz lubaczewski
On 7/16/06, Eci Souji <[EMAIL PROTECTED]> wrote: So we've got a table called "books" and we want to build records of howoften each book is accessed and when.  How would you store suchinformation so that it wouldn't become a huge unmanageable table? Before I go out trying to plan something like this

Re: [GENERAL] doesn't recognize "!=-" (not equal to a negative value)

2006-07-13 Thread hubert depesz lubaczewski
On 7/11/06, Paul Tilles <[EMAIL PROTECTED]> wrote: Yes.  That works.  I think that the parser should work properly either way.it works properly. just the proper way of functioning is not the one you would like to have.you can simply add this operator: CREATE FUNCTION not_equals_minus(int8, int8) RE

Re: [GENERAL] Modeling Tool

2006-07-07 Thread hubert depesz lubaczewski
On 7/6/06, Rodrigo Sakai <[EMAIL PROTECTED]> wrote:   Anyone knows a good tool for do the reverse engineering of a postgresql database? I tried to use DBDesigner, but I couldn't get the relationships!we used case studio 2. worked quite well.depesz-- http://www.depesz.com/ - nowy, lepszy

Re: [GENERAL] stored procedures

2006-07-05 Thread hubert depesz lubaczewski
On 6/30/06, Alain Roger <[EMAIL PROTECTED]> wrote: i'm migrating some SP from MySQL to PostgreSQL 8.1.xI would like to know if it is possible to return aresult of a select request and also a simple interger...that's definitelly possible (and by the way - is was possi ble years before mysql implemen

Re: [GENERAL] A slow query - Help please?

2006-06-20 Thread hubert depesz lubaczewski
On 6/19/06, Alban Hertroys <[EMAIL PROTECTED]> wrote: I found a way that works, and is indeed quite a bit faster. It is evenuglier than what you proposed. The problem wasn't the "order by" in thesubquery, but the "order by" combined with the "union": sorry, i always forget about  the fact that unio

Re: [GENERAL] A slow query - Help please?

2006-06-17 Thread hubert depesz lubaczewski
On 6/16/06, Alban Hertroys <[EMAIL PROTECTED]> wrote: We really need this solved. Isn't anybody able to shed some light onthis? Is it possible to make this query use an index scan, preferablyw/o disabling sequential scanning?ditch the inheritance. it is no good, and makes everything too complicated

Re: [GENERAL] Best practice to grant all privileges on all bjects in database?

2006-05-26 Thread hubert depesz lubaczewski
On 5/26/06, Jim Nasby <[EMAIL PROTECTED]> wrote: Only helps if the OP is willing to run on HEAD; grant on sequence isnot in 8.1 (at least not according to the docs).you can grant on sequences using syntax for tables. works:([EMAIL PROTECTED]:5810) 08:59:21 [depesz] # create sequence test;CREATE SEQ

<    1   2   3   4   5   6   >