Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Bruce Momjian
Bruce Momjian wrote: > > > > 3) There are no AFTER Rules, making, for example, a rule with a table > > check on > > > > the new data impractical, so you'd want to use Triggers or Constraints > > > > > > We have changed ordering in 7.3 where I think INSERT rules are _after_ > > > the insert. > >

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Bruce Momjian
Josh Berkus wrote: > > Bruce, > > > > 1) Rules can't use indexes to do their processing, so Rules which query > large > > > secondary tables can be a bad idea (maybe this has changed?) > > > > I don't think this is true. Rewrite is before optimizer so it should be > > optimized just the same.

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Josh Berkus
Bruce, > > 1) Rules can't use indexes to do their processing, so Rules which query large > > secondary tables can be a bad idea (maybe this has changed?) > > I don't think this is true. Rewrite is before optimizer so it should be > optimized just the same. I was speaking if the Rule has to d

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Bruce Momjian
Josh Berkus wrote: > > Bruce, Richard, > > > Triggers are mostly for testing/modifying the row being > > inserted/updated, while rules are better for affecting other rows or > > other tables. > > Hmmm. Thought that there were also some other criteria: > > 1) Rules can't use indexes to do their

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Josh Berkus
Bruce, Richard, > Triggers are mostly for testing/modifying the row being > inserted/updated, while rules are better for affecting other rows or > other tables. Hmmm. Thought that there were also some other criteria: 1) Rules can't use indexes to do their processing, so Rules which query large

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread Tom Lane
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > We have the following query: > SELECT certificate_id > INTO TEMP TABLE x_certs > FROM certificate > WHERE cert_status = 0 AND > certificate_id BETWEEN AND AND > client_id IN (1, 2, 3) > ORDER BY certificate_i

Re: [SQL] Accent-insensitive

2002-12-06 Thread Joel Burton
On Fri, Dec 06, 2002 at 09:33:10PM +0100, Cédric Dufour (public) wrote: > Use the 'to_ascii' function to convert your string to the "no accent" ASCII > equivalent before accomplishing your comparison > > SELECT foo FROM table WHERE ( to_ascii(foo) ILIKE to_ascii('caractères > accentués') ); > > T

Re: [SQL] Accent-insensitive

2002-12-06 Thread Cédric Dufour (public)
Use the 'to_ascii' function to convert your string to the "no accent" ASCII equivalent before accomplishing your comparison   SELECT foo FROM table WHERE ( to_ascii(foo) ILIKE to_ascii('caractères accentués') );   This does not work with all database locale (LATIN1 is OK, but LATIN9 is not).

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread Bruce Momjian
It should lock only the rows you retrieved, but I have no idea how FOR UPDATE and INTO TEMP behave. My guess is that it should work fine, but I have never seen those two used together before. --- D'Arcy J.M. Cain wrote: > W

[SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread D'Arcy J.M. Cain
We have the following query: SELECT certificate_id INTO TEMP TABLE x_certs FROM certificate WHERE cert_status = 0 AND certificate_id BETWEEN AND AND client_id IN (1, 2, 3) ORDER BY certificate_id FOR UPDATE; Is there any reason that this query should

Re: [SQL] order by a "select as" determined by case statement

2002-12-06 Thread Stephan Szabo
On Fri, 6 Dec 2002, FatTony wrote: > I'm not a db guru by any means so please forgive me if this has an easy > solution. > > Scenario: > > Want to sort by an alias for SELECT AGE(). Problem is the timestamps for > the SELECT AGE will be determined by the value of another column, thus > the use of

[SQL] order by a "select as" determined by case statement

2002-12-06 Thread FatTony
I'm not a db guru by any means so please forgive me if this has an easy solution. Scenario: Want to sort by an alias for SELECT AGE(). Problem is the timestamps for the SELECT AGE will be determined by the value of another column, thus the use of CASE. What I thought would work. SELECT tblticke

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Bruce Momjian
No, the rule will affect all the rows using one query. --- Jean-Luc Lachance wrote: > Thanks for the info. > > Do you mean that if an update affects more than one row I should use > triggers because the rules will be execut

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Jean-Luc Lachance
Thanks for the info. Do you mean that if an update affects more than one row I should use triggers because the rules will be executed only once? JLL Richard Huxton wrote: > > On Friday 06 Dec 2002 4:03 pm, Jean-Luc Lachance wrote: > > Hi all! > > > > Is there a guideline on the use of rules co

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Bruce Momjian
My book has a section on that: http://www.postgresql.org/docs/awbook.html Triggers are mostly for testing/modifying the row being inserted/updated, while rules are better for affecting other rows or other tables. Jean-Luc Lachance wrote: > Hi all! > > Is there a guideline on the use of

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Richard Huxton
On Friday 06 Dec 2002 4:03 pm, Jean-Luc Lachance wrote: > Hi all! > > Is there a guideline on the use of rules compared to triggers when both > can be use to achieve the same result? If I can use rules I do. Rules rewrite the query so are processed once, whereas triggers get processed for every r

[SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Jean-Luc Lachance
Hi all! Is there a guideline on the use of rules compared to triggers when both can be use to achieve the same result? JLL ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] Accent-insensitive

2002-12-06 Thread Pedro Igor
Does have PostgreSQL some option to allow me execute selects accent-insensitive ? I can´t find any reference, including the manual   Pedro Igor

Re: [SQL] Case-insensitive

2002-12-06 Thread Richard Huxton
On Friday 06 Dec 2002 12:33 pm, Pedro Igor wrote: > Someone knows how config the postgresql for case-insensitive mode ? There isn't really a case-insensitive mode (for various reasons to do with locales AFAICT). There are various case-insensitive comparisons: ILIKE instead of LIKE etc. A very c

[SQL] Case-insensitive

2002-12-06 Thread Pedro Igor
Someone knows how config the postgresql for case-insensitive mode ?   Pedro Igor