[GENERAL] How-To: Aggregate data from multiple rows into a delimited list.

2007-07-02 Thread D. Dante Lorenso
This is not a question, but a solution. I just wanted to share this with others on the list in case it saves you a few hours of searching... I wanted to select several rows of data and have them returned in a single record with the rows joined by a delimiter. Turns out this is very easy to d

[GENERAL] How do I aggregate data from multiple rows into a delimited list?

2007-07-03 Thread D. Dante Lorenso
I want to select several rows of data and have them returned in a single record with the rows joined by a delimiter. It would be great if this could be done in a generic way possibly using the GROUP BY like this: SELECT a.id, a.name, STR_SUM(b.name, ',') AS b_names FROM a, b WHERE a.i

Re: [GENERAL] How do I aggregate data from multiple rows into a delimited list?

2007-07-03 Thread D. Dante Lorenso
Berend Tober wrote: D. Dante Lorenso wrote: I want to select several rows of data and have them returned in a single record with the rows joined by a delimiter. Review the User Comments at "http://www.postgresql.org/docs/8.0/interactive/sql-createaggregate.html"; for some ideas.

[GENERAL] SELECT ... FOR UPDATE performance costs? alternatives?

2007-08-15 Thread D. Dante Lorenso
All, I have a stored procedure that I use to manage a queue. I want to pop an item off the queue to ensure that only one server is processing the queue item, so inside PGSQL, use SELECT ... FOR UPDATE to lock the row. Here's how I pop the queue item: ---

Re: [GENERAL] SELECT ... FOR UPDATE performance costs? alternatives?

2007-08-15 Thread D. Dante Lorenso
Erik Jones wrote: On Aug 15, 2007, at 2:39 PM, [EMAIL PROTECTED] wrote: Erik Jones wrote: On Aug 15, 2007, at 1:09 PM, D. Dante Lorenso wrote: ...to ensure that only one server is processing the queue item, so inside PGSQL, use SELECT ... FOR UPDATE to lock the row... When my server is

Re: [GENERAL] SELECT ... FOR UPDATE performance costs? alternatives?

2007-08-16 Thread D. Dante Lorenso
Douglas McNaught wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: How quickly after you update the row status are you comitting (and releasing locks)? I am calling a stored proc from PHP. Since I do not begin a transaction, I assume that my call is automatically commit

Re: [GENERAL] SELECT ... FOR UPDATE performance costs? alternatives?

2007-08-16 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: Douglas McNaught wrote: How quickly after you update the row status are you comitting (and releasing locks)? I am calling a stored proc from PHP. Since I do not begin a transaction, I assume that my call

Re: [GENERAL] Using oid as pkey

2007-08-20 Thread D. Dante Lorenso
Michael Glaesemann wrote: On Aug 20, 2007, at 16:58 , Ed L. wrote: You'd have to specify your table WITH OIDS anyway as they're no longer used by default for table rows, so there's really nothing to be gained by using oids. How exactly can you get rid of OIDs when using a language like PHP?

Re: [GENERAL] Using oid as pkey

2007-08-20 Thread D. Dante Lorenso
Rainer Bauer wrote: "D. Dante Lorenso" wrote: Using a brain-dead sample table that looks like this: CREATE table some_table ( col0 SERIAL, col1 VARCHAR, col2 VARCHAR ); I want to do something like this: I

Re: [GENERAL] Is there a better way to do this?

2007-08-28 Thread D. Dante Lorenso
Wei Weng wrote: I want to implement something like the following: CREATE OR REPLACE FUNCTION AddDays You don't know how many seconds are in a day, so just add the days using SQL. RETURN time + (days || ' days')::INTERVAL; You don't even need to make that a function, just do that you

Re: [GENERAL] Is there a better way to do this?

2007-08-28 Thread D. Dante Lorenso
Michael Glaesemann wrote: On Aug 28, 2007, at 16:55 , D. Dante Lorenso wrote: RETURN time + (days || ' days')::INTERVAL; It's bad practice to concatenate like this. Use time + days * interval '1 day' and be done with it. Why? Is this functionality expected to b

Re: [GENERAL] Is there a better way to do this?

2007-08-28 Thread D. Dante Lorenso
Michael Glaesemann wrote: On Aug 28, 2007, at 17:22 , D. Dante Lorenso wrote: Michael Glaesemann wrote: On Aug 28, 2007, at 16:55 , D. Dante Lorenso wrote: RETURN time + (days || ' days')::INTERVAL; It's bad practice to concatenate like this. Use time + days * interval

Re: [GENERAL] Event-driven programming?

2007-09-12 Thread D. Dante Lorenso
Pavel Stehule wrote: 2007/9/12, Jay Dickon Glanville <[EMAIL PROTECTED]>: - I write a function (it doesn't matter what language it's in: PL/pgSQL, PL/Java, etc) - I register that function as a "post-commit" callback function - when a client commits a transaction, the function gets called, and th

Re: [GENERAL] how to know the current size of a database

2007-09-19 Thread D. Dante Lorenso
[EMAIL PROTECTED] wrote: I want to know about the size of my database. For example, I want to know how many Mb of data for current myDatabase database in a postgres server. SELECT pg_size_pretty(pg_database_size(current_database())); -- Dante ---(end of broadcast)-

[GENERAL] Using RETURNING with INTO inside pgsql

2007-09-20 Thread D. Dante Lorenso
Not really a question here, I just wanted to share my joy with the group. I'm loving the new RETURNING clause in PostgreSQL. This is really cool stuff ... 8< CREATE OR REPLACE FUNCTION "public"."testfunc" () RETURNS bigint AS $body$ DECLARE my_var

[GENERAL] Problem with BYTEA, CAST, and pg_dump

2007-10-22 Thread D. Dante Lorenso
All, I'm trying to use the crypt and decrypt functions from contrib and have installed them into my database. The definition for crypt seems to require that I use BYTEA datatype to input the data I need to encrypt. All of my data is either TEXT or VARCHAR, though and not BYTEA. I was trying

Re: [GENERAL] Selecting tree data

2007-10-25 Thread D. Dante Lorenso
Pat Maddox wrote: I'd like to store some tree data in my database. I want to be able to sort the data but maintain a tree structure Is it possible to pull all the data like that with one query? How do I need to structure the table, and what query do I have to run in order to make it happen?

[GENERAL] pg_dump not including custom CAST?

2007-11-16 Thread D. Dante Lorenso
All, I did this in my database: CREATE CAST (VARCHAR AS BYTEA) WITHOUT FUNCTION; But when I use pg_dump to dump the database and use pg_restore to bring it back on a freshly created database, the CAST is the only part of the restore which is missing. I'm using PostgreSQL 8.2.4 for both th

[GENERAL] Function to convert from TEXT to BYTEA?

2007-12-11 Thread D. Dante Lorenso
All, I want to use the ENCRYPT and DECRYPT functions from contrib, but they require inputs of BYTEA. My data is in VARCHAR and TEXT fields and when I try to use the contrib functions, they complain about wrong datatypes. Is there a string function or something that will take a VARCHAR or TE

Re: [GENERAL] Function to convert from TEXT to BYTEA?

2007-12-12 Thread D. Dante Lorenso
Richard Huxton wrote: D. Dante Lorenso wrote: I want to use the ENCRYPT and DECRYPT functions from contrib, but they require inputs of BYTEA. My data is in VARCHAR and TEXT fields and when I try to use the contrib functions, they complain about wrong datatypes. Is there a string function

[GENERAL] Extract last 4 characters from string?

2007-12-12 Thread D. Dante Lorenso
All, Getting the first 4 characters from the begining of a string is easy enough: SELECT SUBSTR('ABCDEFGHIJKLMNOP', 1, 4); Returns 'ABCD'. But getting the last 4 characters appears to be a little more work and is ugly: SELECT SUBSTR('ABCDEFGHIJKLMNOP', LENGTH('ABCDEFGHIJKLMNOP') - 3, 4)

Re: [GENERAL] Extract last 4 characters from string?

2007-12-12 Thread D. Dante Lorenso
Rodrigo De León wrote: On Dec 12, 2007 4:11 PM, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: Is there an easy (preferred) method that I'm missing? select substring('ABCDEFGHIJKLMNOP' from '$'); Thanks! Now, since I'd like to see a number in ther

[GENERAL] Need LIMIT and ORDER BY for UPDATE

2007-12-12 Thread D. Dante Lorenso
All, I'd really like to have ORDER BY and LIMIT for UPDATE and DELETE commands. Is this possible? UPDATE invoice i SET reserve_ts = NOW() + '1 hour'::timestamp FROM account a WHERE a.acct_id = i.acct_id AND i.reserve_ts < NOW() AND a.status = 'A' AND i.is_paid IS FALSE ORDER B

Re: [GENERAL] Need LIMIT and ORDER BY for UPDATE

2007-12-13 Thread D. Dante Lorenso
John D. Burger wrote: D. Dante Lorenso wrote: I'd really like to have ORDER BY and LIMIT for UPDATE and DELETE commands. Is this possible? UPDATE invoice i SET reserve_ts = NOW() + '1 hour'::timestamp FROM account a WHERE a.acct_id = i.acct_id AND i.reserve_t

Re: [GENERAL] For the SQL gurus out there

2007-12-13 Thread D. Dante Lorenso
Uwe C. Schroeder wrote: Ok, something I've been toying around with for a while. Here's the scenario: Imagine a blogging app. I have a table for blogs with a blog_id (primary key) and a table blog_comments also with a comment_id as primary key and a foreign key holding the blog_id the post belong

Re: [GENERAL] Need LIMIT and ORDER BY for UPDATE

2007-12-13 Thread D. Dante Lorenso
Bill Moran wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> wrote: All, I'd really like to have ORDER BY and LIMIT for UPDATE and DELETE commands. Is this possible? UPDATE invoice i SET reserve_ts = NOW() + '1 hour'::timestamp FROM account a WHE

[GENERAL] Problem with index when using function

2007-12-31 Thread D. Dante Lorenso
All, I have a weird situation where my index IS used when I use a query that hard-codes a value but it does NOT use the index when the value is returned from a PGSQL function: == DOES NOT WORK

Re: [GENERAL] Problem with index when using function

2007-12-31 Thread D. Dante Lorenso
scan will evaluate the comparison value only once, not once at each row, it is not valid to use a VOLATILE function in an index scan condition.)" -- Dante D. Dante Lorenso wrote: All, I have a weird situation where my index IS used when I use a query that hard-codes a value but it do

Re: [GENERAL] Need efficient way to do comparison with NULL as an option

2008-01-04 Thread D. Dante Lorenso
D. Dante Lorenso wrote: I'm looking for an operator that will compare NULL with NULL and evaluate as TRUE. I have a BIGINT column which might contain NULL values. I want to pass a value to compare with that column in my WHERE clause. If the value I'm comparing is 0, I want it to

[GENERAL] Need efficient way to do comparison with NULL as an option

2008-01-04 Thread D. Dante Lorenso
All, I'm looking for an operator that will compare NULL with NULL and evaluate as TRUE. I have a BIGINT column which might contain NULL values. I want to pass a value to compare with that column in my WHERE clause. If the value I'm comparing is 0, I want it to match the NULL values. Here

Re: [GENERAL] Need efficient way to do comparison with NULL as an option

2008-01-04 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: I'm looking for an operator that will compare NULL with NULL and evaluate as TRUE. If the value I'm comparing is 0, I want it to match the NULL values. [ raised eyebrow... ] Sir, you need to rethin

Re: [GENERAL] Need efficient way to do comparison with NULL as an option

2008-01-04 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: I'm looking for an operator that will compare NULL with NULL and evaluate as TRUE. regression=# select null IS NOT DISTINCT FROM 42; ?column? -- f (1 row) regression=# select null IS NOT DISTINC

[GENERAL] WHERE vs ORDER BY vs LIMIT why not using the correct index?

2008-01-08 Thread D. Dante Lorenso
All, I have a simple query: SELECT tcq_id FROM queue q WHERE q.status = 'D' ORDER BY tcq_id ASC LIMIT 1; What I'm trying to do is find all the items in the queue which have a status of 'D' and then select the oldest item first. My data is very skewed such that there are not many re

[GENERAL] Cascading Trigger - changing row on delete does not delete row

2008-02-24 Thread D. Dante Lorenso
All, I have 2 tables which both have triggers on them. When I delete a row on table A, a cascading trigger ends up modifying rows in table B. The modified rows in table B trigger an update on rows in table A which happens to be the same row that I am trying to delete. I don't get any error

[GENERAL] Cascading Trigger - changing row on delete does not delete row

2008-02-24 Thread D. Dante Lorenso
All, I have 2 tables which both have triggers on them. When I delete a row on table A, a cascading trigger ends up modifying rows in table B. The modified rows in table B trigger an update on rows in table A which happens to be the same row that I am trying to delete. I don't get any error

[GENERAL] Cascading Trigger - changing row on delete does not delete row

2008-02-25 Thread D. Dante Lorenso
All, I have 2 tables which both have triggers on them. When I delete a row on table A, a cascading trigger ends up modifying rows in table B. The modified rows in table B trigger an update on rows in table A which happens to be the same row that I am trying to delete. I don't get any error

[GENERAL] How to modify ENUM datatypes?

2008-04-22 Thread D. Dante Lorenso
All, In the past I have used foreign keys to lookup tables for small lists of values that I now think ENUM could do the job of. I was hoping that by using ENUM, I would avoid having to do joins in my queries, and that I'd be making the data more robust and faster. I used to have a table for

Re: [GENERAL] How to modify ENUM datatypes?

2008-04-22 Thread D. Dante Lorenso
Andreas 'ads' Scherbaum wrote: On Tue, 22 Apr 2008 20:58:30 +0800 Craig Ringer wrote: D. Dante Lorenso wrote: The problem is that once I create a column in my account table that uses this 'account_type' datatype, I can't seem to change or add to it any more. I want t

Re: [GENERAL] How to modify ENUM datatypes?

2008-04-22 Thread D. Dante Lorenso
Scott Marlowe wrote: On Tue, Apr 22, 2008 at 2:45 PM, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: So, the advice here is "don't use ENUM"? I was really hoping that it would be more efficient to not have to do all the foreign keys and joins for tables that may have 4-5 en

Re: [GENERAL] How to modify ENUM datatypes?

2008-04-24 Thread D. Dante Lorenso
Andrew Sullivan wrote: On Wed, Apr 23, 2008 at 07:46:07PM -0400, brian wrote: Absolutely true. Which is odd, because this example is trotted out whenever there's a thread about ENUMs. I don't think it's odd at all. In my view, the people who think enums are a good datatype for databases are ex

Re: [GENERAL] How to modify ENUM datatypes?

2008-04-24 Thread D. Dante Lorenso
Alvaro Herrera wrote: D. Dante Lorenso wrote: Or, here's another way to look at it ... make it easier to modify ENUM datatypes because we all know that you will eventually need that feature whether you males, females, and unknowns think so or not. Agreed. Let's keep in min

Sync some database tables, but not others ... WAS Re: [GENERAL] How to modify ENUM datatypes?

2008-04-25 Thread D. Dante Lorenso
Tino Wildenhain wrote: D. Dante Lorenso wrote: Alvaro Herrera wrote: D. Dante Lorenso wrote: Or, here's another way to look at it ... make it easier to modify ENUM datatypes because we all know that you will eventually need that feature whether you males, females, and unknowns think

[GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-10 Thread D. Dante Lorenso
Instead of doing this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able to do this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF (col1name BIGIN

[GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Instead of doing this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able to do this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF (col1name BIGIN

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Pavel Stehule wrote: Hello 2008/5/10 D. Dante Lorenso <[EMAIL PROTECTED]>: Instead of doing this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: I'd like to be able to do this: CREATE OR REPLACE FUNCTION "my_custom_func" (in_value bigint) RETURNS SETOF (col1name BIGINT, col2name TEXT, ...) AS You realize of course that you can do this *t

[GENERAL] Need timestamp function that will change within a transaction

2008-05-14 Thread D. Dante Lorenso
I'd like to find a timestamp function that WILL change within a transaction. This function will return to me a 15 digit BIGINT number in base10: SELECT FLOOR(EXTRACT(EPOCH FROM NOW()) * 10)::bigint; The problem is that NOW() does not change within a transaction and so I keep getting the

[GENERAL] convert very large unsigned numbers to base62?

2008-05-14 Thread D. Dante Lorenso
I'd like to convert very large unsigned numbers (ala bigint) to a text string using base62. I created this PL/PERL function to do the trick: CREATE OR REPLACE FUNCTION "public"."ls_crypt_convert_base" (in_value text, in_base integer) RETURNS text AS $body$ my ($value, $

Re: [GENERAL] convert very large unsigned numbers to base62?

2008-05-14 Thread D. Dante Lorenso
Stuart Cooper wrote: I'd like to convert very large unsigned numbers (ala bigint) to a text string using base62. I created this PL/PERL function to do the trick: base 62 is cruel and unusual punishment. Introduce two more printing characters to your set a..z, A..Z, 0..9 such as "_" and "!" and

[GENERAL] PostgreSQL executing my function too many times during query

2008-05-15 Thread D. Dante Lorenso
I have several records in my database which have encrypted fields. I want to find all the ones that match a certain format but do NOT match another. My problem is that the 'cc_encrypt' function is being executed for every matching row in the table instead of just once. The function was defi

Re: [GENERAL] PostgreSQL executing my function too many times during query

2008-05-15 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: This format causes the function to execute too many times: SELECT COUNT(*) AS result FROM credit_card WHERE card_number_enc = cc_encrypt('4111---', 'pwd')

Re: [GENERAL] PostgreSQL executing my function too many times during query

2008-05-16 Thread D. Dante Lorenso
Tom Lane wrote: "D. Dante Lorenso" <[EMAIL PROTECTED]> writes: So, that not being the problem, any ideas? Is it an 8.2.4 thing? I can't reproduce any such problem in 8.2 branch tip, and a desultory scan of the CVS history back to 8.2.4 doesn't turn up any obviousl

[GENERAL] Need Tool to sync databases with 8.3.1

2008-06-14 Thread D. Dante Lorenso
All, I used to rave about how great the EMS PostgreSQL tools were, but lately I've been disappointed by the lack of support for their Database Comparer 2007 for PostgreSQL. I need a tool that will compare 2 database schemas and allow me to migrate changes from one database to another. What

[GENERAL] Need Tool to sync databases with 8.3.1

2008-06-15 Thread D. Dante Lorenso
All, I used to rave about how great the EMS PostgreSQL tools were, but lately I've been disappointed by the lack of support for their Database Comparer 2007 for PostgreSQL. I need a tool that will compare 2 database schemas and allow me to migrate changes from one database to another. What

[GENERAL] Easy way to alias all columns in a table by adding a prefix or suffix?

2008-08-04 Thread D. Dante Lorenso
All, I have 2 tables with a lot of columns with similar names. I'd like to join both tables and include all columns from each without naming collisions. I can use the 'AS' to rename a single column, but is there a way to do the rename in bulk by just appending a prefix or suffix to the colu

Re: [GENERAL] MySQL LAST_INSERT_ID() to Postgres

2008-08-28 Thread D. Dante Lorenso
Scott Marlowe wrote: On Thu, Aug 28, 2008 at 3:38 PM, Bill <[EMAIL PROTECTED]> wrote: I am new to PostgreSQL but it seems to me that lastval() will only work if the insert does not produce side effects that call nextval(). Consider the case where a row is inserted into a table that has an after

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread D. Dante Lorenso
Matthew Wilson wrote: On Tue 02 Sep 2008 04:40:55 PM EDT, Scott Marlowe wrote: On Tue, Sep 2, 2008 at 2:35 PM, Matthew Wilson <[EMAIL PROTECTED]> wrote: On Tue 02 Sep 2008 04:19:41 PM EDT, Scott Marlowe wrote: If the two subordinate tables ALWAYS have to point to the same place, why two tables

[GENERAL] Full outer join? Cross product? How to blend two queries into single row?

2008-09-04 Thread D. Dante Lorenso
a.join_column = b.join_column); Is this how to do it, or is there a simpler syntax I'm missing? What's the formal terminology for what I'm doing here? Is there a way to specify a FULL OUTER JOIN without naming the join column since I don't need one? -- Dante -- D

Re: [GENERAL] Numbering rows

2008-10-15 Thread D. Dante Lorenso
27;plperl' VOLATILE RETURNS NULL ON NULL INPUT; -- Perhaps you can use PL/PERL and a function like these to modify "global" variables that you can increment as you do your select. Something like: SELECT global_var_set(0); SELECT global_var_inc() AS row_counte

Re: [GENERAL] Equivalent for AUTOINCREMENT?

2008-10-31 Thread D. Dante Lorenso
or 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- -- D. Dante Lorenso [EMAIL PROTECTED] -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Most efficient report of number of records in all tables?

2007-02-26 Thread D. Dante Lorenso
All, I can find the names of all tables in the database with this query: SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY table_name ASC; Then, in code, I can loop through all t

Re: [GENERAL] Most efficient report of number of records in all tables?

2007-02-26 Thread D. Dante Lorenso
] [mailto:pgsql-general- [EMAIL PROTECTED] On Behalf Of D. Dante Lorenso Sent: Monday, February 26, 2007 2:20 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Most efficient report of number of records in all tables? All, I can find the names of all tables in the database with this query: SE

Re: [GENERAL] Delete all records NOT referenced by Foreign Keys

2003-12-13 Thread D. Dante Lorenso
Bruno Wolff III wrote: On Sat, Dec 13, 2003 at 02:20:15 -0600, "D. Dante Lorenso" <[EMAIL PROTECTED]> wrote: I'd like to run a clean up command on my tables to eliminate rows that I'm no longer using in the database. I want to do something like this: DEL

Re: [GENERAL] Delete all records NOT referenced by Foreign Keys

2003-12-14 Thread D. Dante Lorenso
Martijn van Oosterhout wrote: On Sat, Dec 13, 2003 at 09:48:16PM -0600, D. Dante Lorenso wrote: This is something very ugly indeed and is what I'll have to resort to unless I can find something cleaner. Ideally, I would be able to run this cleanup on a subset of the table data after an i

Re: [GENERAL] How to navigate tree without CONNECT BY?

2003-12-19 Thread D. Dante Lorenso
Joe Conway wrote: D. Dante Lorenso wrote: I have a simple table that I'd like to query to pull out a heirarchy from a tree relationship. What is the best way to do this without a 'CONNECT BY' clause like Oracle has? See connectby() in contrib/tablefunc. Yep. That's wh

Re: [GENERAL] website doc search is extremely SLOW

2003-12-30 Thread D. Dante Lorenso
Marc G. Fournier wrote: On Mon, 29 Dec 2003, D. Dante Lorenso wrote: Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd expect a much fas

Re: [GENERAL] Using indices with long unique IDs.

2004-01-09 Thread D. Dante Lorenso
Sergey Olefir wrote: So the logical choice would be int8, right? Unfortunately quite wrong. Statement of the form: "SELECT * FROM table WHERE id=1" will never use index for id (assumming id is int8) since '1' is of type int4. This is confirmed both by documentation and SQL EXPLAIN (after set enabl

[GENERAL] Bug with rename bigserial column

2004-01-10 Thread D. Dante Lorenso
I just ran into a dump/restore problem with a bigserial column on a renamed table. BIGSERIAL columns when created will automagically create the sequence also. The sequence name is derived from the table name and column name. I had a table named 'audio_usage' and defined a column like this: a

Re: [GENERAL] Drawbacks of using BYTEA for PK?

2004-01-12 Thread D. Dante Lorenso
Tom Lane wrote: Adding an MD5 hash contributes *absolutely zero*, except waste of space, to any attempt to make a GUID. The hash will add no uniqueness that was not there before. The cool thing about a 'GUID' (or in my example a hashed sequence number [sure toss in some entropy if you want it]

[GENERAL] Dump/Restore ordering problem?

2004-01-12 Thread D. Dante Lorenso
First I created a function that selected the next available pin code from a table of pre-defined pin codes: CREATE FUNCTION "public"."get_next_pin_code" () RETURNS varchar AS' DECLARE my_pin_code VARCHAR; BEGIN ... /* this is the pincode we just fetched */ RETUR

Re: [GENERAL] Drawbacks of using BYTEA for PK?

2004-01-12 Thread D. Dante Lorenso
they can try to look up information on other customers by doing: http://domain.com/application/load_record.html?customer_id=12346 http://domain.com/application/load_record.html?customer_id=12344 ...basically walking the sequence. Sure, you will protect against this to happen. NOW