Re: [SQL] parsing audit table

2011-08-16 Thread Jaime Casanova
On Tue, Aug 16, 2011 at 4:02 PM, M. D. wrote: > Hi everyone, > > I'm a bit lazy, or actually in a bit of a crunch.  I added an audit > recording a few months ago, but never really used it much, but today I'm > seeing a bunch of suspicious activity by one user.  Does someone have any > function to

[SQL] parsing audit table

2011-08-16 Thread M. D.
Hi everyone, I'm a bit lazy, or actually in a bit of a crunch. I added an audit recording a few months ago, but never really used it much, but today I'm seeing a bunch of suspicious activity by one user. Does someone have any function to quickly parse this data? I followed this: http://wik

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Igor Neyman
> -Original Message- > From: adam_pgsql [mailto:adam_pg...@witneyweb.org] > Sent: Tuesday, August 16, 2011 7:39 AM > To: pgsql-sql > Subject: which is better: using OR clauses or UNION? > > > Hi, > > I have a query hitting a table of 25 million rows. The table has a text > field ('identi

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread adam_pgsql
On 16 Aug 2011, at 15:09, Tom Lane wrote: > adam_pgsql writes: >> I have a query hitting a table of 25 million rows. The table has a >> text field ('identifier') which i need to query for matching rows. The >> question is if i have multiple strings to match against this field I >> can use multip

[SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Adam Witney
Hi, I have a query hitting a table of 25 million rows. The table has a text field ('identifier') which i need to query for matching rows. The question is if i have multiple strings to match against this field I can use multiple OR sub-statements or multiple statements in a UNION. The UNION see

Re: [SQL] bigint and unix time

2011-08-16 Thread Janiv Ratson
Additional information: If I use the following query: select "time", extract(epoch from (date 'now' - integer '30')), extract(epoch from (date 'now')) from ticket_change The first row looks like this: Bigint, double precision, double precision 128609061500;131085;1313442000 Thanks, Jan

Re: [SQL] bigint and unix time

2011-08-16 Thread Janiv Ratson
Hi and thanks again. I use the following query but it returns me 0 rows (it should return more): SELECT ticket, "time", author, field, oldvalue, newvalue FROM ticket_change where "time" BETWEEN extract(epoch from (date 'now' - integer '30')) AND extract(epoch from (date 'no

Re: [SQL] bigint and unix time

2011-08-16 Thread Janiv Ratson
Hi Adrain and thank you, Trac 0.12 uses microseconds as time value. What do you suggest? Thanks, Janiv. -Original Message- From: Adrian Klaver [mailto:adrian.kla...@gmail.com] Sent: Monday, August 15, 2011 17:14 To: Janiv Ratson Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] bigint and

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread adam_pgsql
Hi Viktor, thanks for your email, gave that a try, but the lower(identifier) LIKE lower('BUGS001884677') OR still comes in quicker than the IN approach thanks adam On 16 Aug 2011, at 12:56, Viktor Bojović wrote: > hi Adam, > im not sure which is faster/slower but, possibly you can sp

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Jasen Betts
On 2011-08-16, adam_pgsql wrote: > > Hi, > > I have a query hitting a table of 25 million rows. The table has a >text field ('identifier') which i need to query for matching rows. The >question is if i have multiple strings to match against this field I >can use multiple OR sub-statements or multi

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Tom Lane
adam_pgsql writes: > I have a query hitting a table of 25 million rows. The table has a > text field ('identifier') which i need to query for matching rows. The > question is if i have multiple strings to match against this field I > can use multiple OR sub-statements or multiple statements in a >

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread David Johnston
-Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of adam_pgsql Sent: Tuesday, August 16, 2011 7:39 AM To: pgsql-sql Subject: [SQL] which is better: using OR clauses or UNION? Hi, I have a query hitting a table of 25 million rows. T

Re: [SQL] bigint and unix time

2011-08-16 Thread Adrian Klaver
On Tuesday, August 16, 2011 2:12:52 am Janiv Ratson wrote: > Hi Adrain and thank you, > Trac 0.12 uses microseconds as time value. > What do you suggest? extract(epoch ..) returns seconds which you are trying to compare to microseconds. The solution would be to divide your 'time' values by 1,000,

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Viktor Bojović
hi Adam, im not sure which is faster/slower but, possibly you can speed it up by using "in" operator ...where lower(identifier) *in *(lower('BUGS001884677')* ,*lower('BUGS001884678') *,*); if you create function based index: CREATE INDEX idx_table_lower_text ON table(*lower*(text_fie

[SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread adam_pgsql
Hi, I have a query hitting a table of 25 million rows. The table has a text field ('identifier') which i need to query for matching rows. The question is if i have multiple strings to match against this field I can use multiple OR sub-statements or multiple statements in a UNION. The UNION see