Re: [SQL] Unique index VS unique constraint

2013-10-05 Thread Sergey Konoplev
erform its function. This index will be created automatically when you add the constraint. -- Kind regards, Sergey Konoplev PostgreSQL Consultant and DBA http://www.linkedin.com/in/grayhemp +1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979 gray...@gmail.com -- Sent via pgsql-sql mailing

Re: [SQL] Can I simplify this somehow?

2013-09-27 Thread Sergey Konoplev
e a look at this module: http://www.postgresql.org/docs/9.3/static/tablefunc.html Particularly look at the crostab(text, text) function. -- Kind regards, Sergey Konoplev PostgreSQL Consultant and DBA http://www.linkedin.com/in/grayhemp +1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979 gr

Re: [SQL] Unique index and unique constraint

2013-07-26 Thread Sergey Konoplev
defer the uniqueness check until the end of transaction if it is constraint, and can not it it is unique index. Correct? http://www.postgresql.org/docs/9.2/static/sql-set-constraints.html -- Kind regards, Sergey Konoplev PostgreSQL Consultant and DBA Profile: http://www.linkedin.com/in/grayhe

Re: [SQL] execute

2013-04-25 Thread Sergey Konoplev
On Thu, Apr 25, 2013 at 9:17 AM, Mauricio Cruz wrote: > execute 'aCad:=aCad array[['||var1||','||var2||']]' What are you going to do using this construction aCad:=aCad array[['||var1||','||var2||']] ? I can not understand the meaning. -

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Sergey Konoplev
ed". > I don't know if this happens, or may sometimes happen, or might happen > in the future, for rows eliminated because of DISTINCT. It is a good point. Nothing guarantees it in a perspective. Optimizer guarantees a stable result but not the way it is reached. -- Sergey Konoplev Datab

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Sergey Konoplev
n value can change even within a single table scan, so no optimizations can be made". So they are guaranteed to behave as you need in your last example. What about optimizing it out in WITH - I would like to listen to hackers' opinion, because for me it looks like a bug. -- Ser

Re: [SQL] Volatile functions in WITH

2013-02-19 Thread Sergey Konoplev
add_item(...) as before > ) > SELECT DISTINCT e.msg > FROM "exp" e > LEFT JOIN "subst" s ON FALSE > > WITH "exp" AS ( -- as before > ) > SELECT DISTINCT s.msg > FROM ( > SELECT e.msg, CAS

Re: [SQL] upsert doesn't seem to work..

2013-02-13 Thread Sergey Konoplev
_hotsales, > loadoltp.st_item_insert.item_showplan, > loadoltp.st_item_insert.item_sms_code, loadoltp.st_item_insert.datetyp_id, > loadoltp.st_item_insert.item_start, loadoltp.st_item_insert.item_end, > loadoltp.st_item_insert.item_validfrom, > loadoltp.st_item_insert.item_validuntil, &g

Re: [SQL] select on many-to-many relationship

2012-11-27 Thread Sergey Konoplev
gt; > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql -- Sergey Konoplev Database and Software Architect http://www.linkedin.com/in/grayhemp Phones: USA +1 415 867 9984 Russi

Re: [SQL] generate_series() with TSTZRANGE

2012-09-13 Thread Sergey Konoplev
tamp, '2012-09-17 > 12:00:00', '1 hour') > AS a OFFSET 1; > > Thanks! > > -- > Wolfe Whalen > wo...@quios.net > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.post

Re: [SQL] returning values from dynamic SQL to a variable

2012-09-10 Thread Sergey Konoplev
CUTE like this: sql := 'select * from public.elt_set_locking(...'; EXECUTE sql INTO v_retcode; Here you will find more info about EXECUTE in plpgsql. http://www.postgresql.org/docs/9.1/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN -- Sergey Konoplev a database a

Re: [SQL] Question regarding modelling for time series

2012-09-05 Thread Sergey Konoplev
3 > Unemployment; release: 2011/09/01; reporting: 2011/08/01; value: 4 > > That are the series I want to get from the db. > > > --Alex -- Sergey Konoplev a database and software architect http://www.linkedin.com/in/grayhemp Jabber: gray...@gmail.com Skype: gray-hemp P

Re: [SQL] Question regarding modelling for time series

2012-09-04 Thread Sergey Konoplev
It will be. You will probably need some more optimization/partitioning depending on the data distribution however it can be done later. > > > > Thank you very much! > > > --Alex > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes t

Re: [SQL] Need to Iterate the record in plpgsql

2012-09-04 Thread Sergey Konoplev
t; LOOP > > END LOOP > END LOOP > > As per the example, How can I iterate pre stored record. > > Please let me know if you have any suggestions. > > Thanks & Regards, > Ramkumar > > > > > -- Sergey Konoplev a database architect, soft

Re: [SQL] DELETE using an outer join

2012-07-20 Thread Sergey Konoplev
JOIN other_table ... > > where the respecification of the table in USING would be understood > to mean the target table. Right now this is an error case because > of duplicate table aliases. Yes, the OP has already pointed me to it. Thank you for your explanation. -- Sergey

Re: [SQL] DELETE using an outer join

2012-07-20 Thread Sergey Konoplev
>> table name to be respecified in USING, but there are complications. >> >> However it works. >> >> DELETE FROM some_table USING some_table AS s >> WHERE >> some_table.col1 = s.col1 AND >> some_table.col2 = s.col2 AND >> some_table.id <

Re: [SQL] DELETE using an outer join

2012-07-20 Thread Sergey Konoplev
are complications. However it works. DELETE FROM some_table USING some_table AS s WHERE some_table.col1 = s.col1 AND some_table.col2 = s.col2 AND some_table.id < s.id; -- Sergey Konoplev a database and software architect http://www.linkedin.com/in/grayhemp Jabber: gray..

Re: [SQL] DELETE using an outer join

2012-07-19 Thread Sergey Konoplev
ter than one with the sub query and NOT IN. ps. May be this example is worth to append to the documentation? -- Sergey Konoplev a database architect, software developer at PostgreSQL-Consulting.com http://www.postgresql-consulting.com Jabber: gray...@gmail.com Skype: gray-hemp Phone: +791606

Re: [SQL] How to use hstore

2012-06-04 Thread Sergey Konoplev
nt to ensure that they are virus free and no responsibility > is accepted by Jan Eskilsson  for any loss or damage arising in any > way from receipt or use thereof. > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http:

Re: [SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]

2010-10-25 Thread Sergey Konoplev
99DD6  +49 151 2300 9283  computing @ chaos > claudius > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Sergey Konoplev Blog: http://gray-hemp.blogspot.c

Re: [SQL] unique fields

2010-09-23 Thread Sergey Konoplev
sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linkedin.com/in/grayhemp / JID/GTalk: gray...@gmail.com / Skype: gray-hemp /

Re: [SQL] Use "CREATE USER" in plpgsql function

2010-09-15 Thread Sergey Konoplev
uot;inUse"=TRUE WHERE > "credId"=creds."credId"; >     CREATE USER creds."userName" WITH PASSWORD creds."userPassword" > IN GROUP ta_users; - there is error occured >             cred:=N'pass'; >     else >         cre

Re: [SQL] Use "CREATE USER" in plpgsql function

2010-09-14 Thread Sergey Konoplev
brace" this parameter (i mean creds."userName")? Show the whole function please. > > Thanks > -- > -- > Alexander > -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linkedin.com/in/grayhemp / JID/GTalk: gray...@gmail.com / Skype:

Re: [SQL] plpgsql out parameter with select into

2010-08-18 Thread Sergey Konoplev
lane > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linkedin.com/in/grayhemp / JID/GTalk: gr

Re: [SQL] plpgsql out parameter with select into

2010-08-18 Thread Sergey Konoplev
What is your PG version? 2010/8/18 Horváth Imre : > It don't work... > > Only select into status * from... works. > > Imre Horvath > > 2010. 08. 18, szerda keltezéssel 09.42-kor Sergey Konoplev ezt írta: >> Hi, >> >> SELECT column_name >> INTO

Re: [SQL] Question about POSIX Regular Expressions performance on large dataset.

2010-08-17 Thread Sergey Konoplev
of generally indexing to match regexp :( >> , so, tablescans for this huge dataset. >> >> What do you think of this? >> >> Sincerely, >> >> Ildefonso Camargo >> > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) &g

Re: [SQL] plpgsql out parameter with select into

2010-08-17 Thread Sergey Konoplev
   status integer; > $BODY$ >        select into status _status from testfunc1(); > $BODY$ > language plpgsql; > > testfunc2 works, testfunc3 not. > > Thanks in advance: > Imre Horvath > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To m

Re: [SQL] How to store Byte strings into a table.

2010-07-04 Thread Sergey Konoplev
--------- > Trinath Somanchi, > -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linkedin.com/in/grayhemp / JID/GTalk: gray...@gmail.com / Skype: gray-hemp / ICQ: 29353802 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to

Re: [SQL] Difference between these two queries ?

2010-06-06 Thread Sergey Konoplev
ql.org/docs/8.4/interactive/queries-table-expressions.html#QUERIES-FROM > > What is the first type of join called ? CROSS JOIN > > and is it possible that they have different execution times ? AFAIK planner would choose the same execution plan in your situation so it is not. -- Sergey

Re: [SQL] Table Design for Hierarchical Data

2010-04-07 Thread Sergey Konoplev
description of ltree: "This module implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure". http://www.postgresql.org/docs/8.4/interactive/ltree.html -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linked

Re: [SQL] Week to date function

2010-03-26 Thread Sergey Konoplev
hink it is better to use date_part('year', day) instead of to_char(...). And may be it is worth to do raise exception when incorrect week specified. -- Sergey Konoplev Blog: http://gray-hemp.blogspot.com / Linkedin: http://ru.linkedin.com/in/grayhemp / JID/GTalk: gray...@gmail.com / Sky

Re: [SQL] Week to date function

2010-03-25 Thread Sergey Konoplev
gt;  2010-03-25 >  2010-03-26 >  2010-03-27 >  2010-03-28 > (7 rows) > > SELECT week2date(2009, 53); >  week2date > ---- >  2009-12-28 >  2009-12-29 >  2009-12-30 >  2009-12-31 >  2010-01-01 >  2010-01-02 >  2010-01-03 > (7 rows) > > SELECT wee