Re: [GENERAL] How to get correct local time

2017-03-29 Thread Vitaly Burovoy
On 3/29/17, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote: > On 3/29/17, Andrus <kobrule...@hot.ee> wrote: >> >> select current_time at time zone 'GMT-2' >> >> returns >> >> "11:54:40.22045+02" >> >> but correct

Re: [GENERAL] How to get correct local time

2017-03-29 Thread Vitaly Burovoy
ing time was changed by one hour a week ago. > Maybe postgres didnt recognized it. > > Posted also in > > http://stackoverflow.com/questions/43090328/how-to-return-correct-local-time-in-postgres > > Andrus. > Try SELECT now(); or SELECT current_timestamp; -- Best regards, Vi

Re: [GENERAL] Simple Query not using Primary Key Index

2017-02-06 Thread Vitaly Burovoy
e many other factors influence to PG's decision including random_page_cost and seq_page_cost for tablespaces; fillfactor for indexes and tables and many more. You have sent neither table DDL nor EXPLAIN ANALYZE result. If a query runs fast enough, I would not pay attention to used access method.

Re: [GENERAL] Simple Query not using Primary Key Index

2017-02-06 Thread Vitaly Burovoy
Scan. That's why it can ignore existing indexes. -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Matching indexe for timestamp

2017-01-09 Thread Vitaly Burovoy
n to use an ordinary type column(s) with range type column(s). P.S.: Postgres can not to use indexes even if they are right because according to a statistics SeqScan will take similar access time. [1]https://www.postgresql.org/docs/9.6/static/rangetypes.html#RANGETYPES-DEFINING -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] The best way to deal with hierarchical data (was: Postgresql query HAVING do not work)

2017-01-04 Thread Vitaly Burovoy
On 1/4/17, Gwork <n...@riseup.net> wrote: > On 1/5/17 2:51 AM, Vitaly Burovoy wrote: >> On 1/4/17, Gwork <n...@riseup.net> wrote: >>> On 1/5/17 2:22 AM, Vitaly Burovoy wrote: >>>> On 1/4/17, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote

Re: [GENERAL] [BUGS] Postgresql query HAVING do not work

2017-01-04 Thread Vitaly Burovoy
On 1/4/17, Gwork <n...@riseup.net> wrote: > On 1/5/17 2:22 AM, Vitaly Burovoy wrote: >> On 1/4/17, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote: >>> On 1/4/17, Gwork <n...@riseup.net> wrote: >>>> Version: Postgresql 9.5 >>>> OS: Deb

Re: [GENERAL] SERIALIZABLE and INSERTs with multiple VALUES

2016-10-12 Thread Vitaly Burovoy
transaction in the same command. I think it is an obvious bug because there is no "concurrent update". There is no update at all. ON CONFLICT handling just does not cover all possible ways which can happen. Normally (without "ON CONFLICT" clause) INSERT raises "duplicate key value viola

Re: [GENERAL] ALTER TABLE without long waiting is possibly ?

2016-10-11 Thread Vitaly Burovoy
FOR UPDATE LIMIT 1 )t WHERE s._pk_column_=t._pk_column_; > Unfortunately I can't test on product servers, so Im looking for some > advice or some one to point me the right direction how I can alter table > today without clients to notice their query is locked and need to wait. [1]

Re: [GENERAL] ZSON, PostgreSQL extension for compressing JSONB

2016-10-05 Thread Vitaly Burovoy
ds. Creating a new dictionary for compressing purposes supposes updating rows of the original table to replace entries to references to a dictionary. -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Update two tables returning id from insert CTE Query

2016-09-27 Thread Vitaly Burovoy
expression* > To update rows of one table by rows from another table you should use UPDATE ... SET ... FROM ... WHERE ... clause described in the docs[1] (see example around the sentence "A similar result could be accomplished with a join:" and note below). [1] https://www.postgresq

Re: [GENERAL] Update two tables returning id from insert CTE Query

2016-09-27 Thread Vitaly Burovoy
..., ... OVER()... FROM ins_table_1 ) ins ON (...) Note than CTEs not have indexes and a join process is not fast (for bigger number of rows). -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] jsonb_set for nested new item?

2016-09-24 Thread Vitaly Burovoy
> On Sep 23, 2016 5:12 PM, "Vitaly Burovoy" <vitaly.buro...@gmail.com> wrote: > On 9/23/16, Deven Phillips <deven.phill...@gmail.com> wrote: >> On Fri, Sep 23, 2016 at 10:14 AM, Deven Phillips >> <deven.phill...@gmail.com> wrote: >>> Is t

Re: [GENERAL] jsonb_set for nested new item?

2016-09-23 Thread Vitaly Burovoy
it can be like: SELECT jsonb_set( CASE WHEN DATA ? 'boo' THEN DATA ELSE jsonb_set(DATA, array['boo'], '{}') END, '{boo,baz}'::text[], '"newvalue"' ) FROM (VALUES('{"foo": "bar"}'::jsonb)) AS t(data) [1] https://www.postgresql.org/docs/devel/static/functions-json.html -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] select date between - PostgreSQL 9.5

2016-09-13 Thread Vitaly Burovoy
: > > > select modified_date from clients ORDER BY modified_date ASC > > > modified_date >> --- >> 2015-07-11 17:23:40 it is 2015 year, more than 1 year ago vv because expression is rewritten as "modified_date <= 2016-09-13 0

Re: [GENERAL] Using timestamp(tz) in C functions

2016-07-29 Thread Vitaly Burovoy
On 7/29/16, Keith Fiske <ke...@omniti.com> wrote: > On Fri, Jul 29, 2016 at 11:49 AM, Vitaly Burovoy <vitaly.buro...@gmail.com> > wrote: > >> On 7/29/16, Keith Fiske <ke...@omniti.com> wrote: >> > On Fri, Jul 29, 2016 at 12:53 AM, Vitaly Burovoy

Re: [GENERAL] Using timestamp(tz) in C functions

2016-07-29 Thread Vitaly Burovoy
On 7/29/16, Keith Fiske <ke...@omniti.com> wrote: > On Fri, Jul 29, 2016 at 12:53 AM, Vitaly Burovoy <vitaly.buro...@gmail.com> > wrote: > >> On 7/28/16, Keith Fiske <ke...@omniti.com> wrote: >> > Working on trying to get a C version of the maintenance

Re: [GENERAL] Using timestamp(tz) in C functions

2016-07-28 Thread Vitaly Burovoy
ime). Please, answer questions: 1. How many rows SPI_execute returns (value of "ret" variable)? 2. Is last_partition_timestamp != NULL? Where it points to? 3. Try to check SPI_result just after SPI_getbinval. Has it error code? -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Returning values from an array of JSONB objects.

2016-04-13 Thread Vitaly Burovoy
On 4/13/16, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote: > On 4/13/16, sighup <r...@sighup.eu> wrote: >> Hi, please excuse either my stupidity or naivety regarding this but I'm >> a bit confused. Give the following basic table structure : >> >&g

Re: [GENERAL] Returning values from an array of JSONB objects.

2016-04-13 Thread Vitaly Burovoy
ve answer, or maybe that should read > 'one I can understand'. > > I'm using PostgreSQL 9.5 on Linux with pgAdmin III on Mac. > > -- > Bill [1] http://www.postgresql.org/docs/9.5/static/functions-json.html -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Slow Query - Postgres 9.2

2016-03-03 Thread Vitaly Burovoy
On 3/2/16, drum.lu...@gmail.com <drum.lu...@gmail.com> wrote: > On 3 March 2016 at 10:33, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote: >> On 3/2/16, drum.lu...@gmail.com <drum.lu...@gmail.com> wrote: >> > Hi all... >> > >> > I'm working

Re: [GENERAL] Slow Query - Postgres 9.2

2016-03-02 Thread Vitaly Burovoy
is 2.8sec! and index scan in ix_notes_jobid_per_type 500rows(loops) * 9.878ms!!! = 4.939sec. Why does it take so long time? For example, index scan in ja_customers_pkey is only 0.781 per row... 10 times faster! What definition of the ix_notes_jobid_per_type? Is it bloated? > Explain analyze link:

Re: [GENERAL] How to ensure that a stored function always returns TRUE or FALSE?

2016-03-02 Thread Vitaly Burovoy
On 3/2/16, Alexander Farber <alexander.far...@gmail.com> wrote: > On Wed, Mar 2, 2016 at 11:09 AM, Vitaly Burovoy <vitaly.buro...@gmail.com> > wrote: > >> On 3/2/16, Alexander Farber <alexander.far...@gmail.com> wrote: >> > >>

Re: [GENERAL] How to ensure that a stored function always returns TRUE or FALSE?

2016-03-02 Thread Vitaly Burovoy
t; Thank you > Alex > [1]https://en.wikipedia.org/wiki/Null_(SQL)#Comparisons_with_NULL_and_the_three-valued_logic_.283VL.29 -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Only owners can ANALYZE tables...seems overly restrictive

2016-02-28 Thread Vitaly Burovoy
config files are copied wrongly). > > -- > john r pierce, recycling bits in santa cruz -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Query plan not updated after dropped index

2016-02-18 Thread Vitaly Burovoy
er the new index is used in an EXPLAIN of any query that use it or not. In the first case do COMMIT, in the second case just do ROLLBACK and leave old index for using. > Thanks! > Victor [1]http://www.postgresql.org/docs/devel/static/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING [2]http://www.

Re: [GENERAL] Actual row order in UPDATE and SELECT FOR UPDATE

2016-02-15 Thread Vitaly Burovoy
lck WHERE t.id=lck.id > > Thank you, > Nikolai [1]http://www.postgresql.org/docs/current/static/queries-with.html -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Question on how to use to_timestamp()

2016-02-14 Thread Vitaly Burovoy
'America/New_York') -- "<=" or just "<"? ORDER BY ... > http://www.postgresql.org/docs/9.5/interactive/functions-formatting.html > "Ordinary text is allowed in to_char templates and will be output literally. > You can put a substring in double quotes to

Re: [GENERAL] Question on how to use to_timestamp()

2016-02-13 Thread Vitaly Burovoy
to_timestamp and to_date exist to handle input formats > that cannot be converted by simple casting. > ERROR: invalid value ":0" for "MI" > DETAIL: Value must be an integer. > Time: 1.016 ms > > Could anyone suggest what it is that I might be doing wrong here? &

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
9.9070...@posteo.de [2]http://www.postgresql.org/message-id/cakoswnkrb0kfwhcw9cvocrmks8huzrpvflr0kkcjuyn6juk...@mail.gmail.com [3]http://www.postgresql.org/message-id/CAKOSWN=wX9Myw4q9mpiqESyizU4tWrGivgbw+3Ef=5q60vi...@mail.gmail.com -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
ips out the >> id and sends it id in the next query again. So the server can compute >> the result set without external dependencies as fast as possible. > > Sounds like what you're really after is a stored procedure, isn't it? Unfortunately, his case is different, because he

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
On 2/9/16, Johannes <jo...@posteo.de> wrote: > Am 09.02.2016 um 00:56 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes <jo...@posteo.de> wrote: >>> Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: >>>> On 2/8/16, Johannes <jo...@posteo.de> wrote: >&g

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
s one row: "(id, col1, col2)", and the second one returns rows "(val1), (val2), (val3), ..." (values of the t1.col1). If you use joining, you get rows: (id, col1, col2, val1) (id, col1, col2, val2) (id, col1, col2, val3) ... where values of the first three columns are

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes <jo...@posteo.de> wrote: > > Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: >> On 2/8/16, Adrian Klaver <adrian.kla...@aklaver.com> wrote: >>> Based on rough guess of the above, without seeing actual table schemas: >>> >>> sel

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes <jo...@posteo.de> wrote: > Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes <jo...@posteo.de> wrote: >>> Am 08.02.2016 um 20:15 schrieb David G. Johnston: >>>> On Mon, Feb 8, 2016 at 12:05 PM, Johan

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
t; t1.t0_id where id = (select max(id) from t0 where col1 = value1 and col2 > = value2 and ...); I don't think it is a good solution because it leads to copying columns from the t0 which is wasting net traffic and increasing complexity at the client side. Moreover it works iff t0 returns only on

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
returns multiple rows. > > begin; > select id, col1, col2, ... from t0 where id = (select max(id) from t0 > where col1 = value1 and col2 = value2 and ...); > select col1 from t1 where t0_id = (select max(id) from t0 where col1 = > value1 and col2 = value2 and ...); > commit; >

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
at client are you using to execute these statements? > > JDBC. I execute both statements at once and iterate through the resultsets. > > Johannes Hmm. Could you clarify why you don't want to pass id from the first query to the second one: select col1 from t1 where t0_id = value_id_from_the_first_query -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
t0 WHERE col1 = value1 and col2 = value2 and ...; SELECT id, col1, col2, ... FROM t0 INNER NATURAL JOIN temptable; SELECT col1 FROM t1 INNER JOIN temptable ON (t0_id = temptable.id); COMMIT; [1]http://www.postgresql.org/docs/9.5/static/sql-createtable.html -- Best regards, Vitaly Buro

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes <jo...@posteo.de> wrote: > Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes <jo...@posteo.de> wrote: >>> Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >>>> Hmm. Could you clarify why you don't want to pass id f

[GENERAL] Was: BUG #13883: Very Important Facility

2016-01-25 Thread Vitaly Burovoy
have notified the > Joomla team with this suggestion. That is as much as I can do to speed > up PostgreSQL uptake in Joomla for now. > > Thanks for providing postgreSQL to us. You are welcome. > > Best wishes, > Dominic -- Best regards, Vitaly Burovoy -- Sent via pgsq

Re: [GENERAL] ERROR: check constraint - PostgreSQL 9.2

2016-01-25 Thread Vitaly Burovoy
ur answers even if he haven't subscribed to the mailing list. [1]http://www.postgresql.org/docs/9.2/static/sql-altertable.html -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-11 Thread Vitaly Burovoy
t; > Hey guys.. > How could I create a timestampandtz index? > CREATE TABLE gorfs.inode_segments > ( > <> > ) -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: Russian, was: Re: [GENERAL] Code of Conduct: Is it time?

2016-01-11 Thread Vitaly Burovoy
quot;gender" not necessarily connected to a gender of real user who is reading the doc and in most cases such pronouns are "masculine", that's why we don't concern to replace "he" to "he/she" or somewhat else. -- Best regards, Vitaly Burovoy -- Sent vi

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-11 Thread Vitaly Burovoy
INTERVAL)". You have to change the condition the way where one part of a condition at an optimization part can be simplified to a constant and the other part of the condition represents a column of an existent index (as it was written in my first answer). -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-10 Thread Vitaly Burovoy
inodes" "t" (cost=0.00..1411147.24 rows=13416537 width=29) > (actual time=94987.224..94987.224 rows=0 loops=1) > Filter: ("timezone"('UTC'::"text", "transaction_timestamp"()) > > (("st_ctime")::timestamp without time zone + '2 years'

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-10 Thread Vitaly Burovoy
On 1/10/16, Vitaly Burovoy <vitaly.buro...@gmail.com> wrote: > On 1/10/16, Saulo Merlo <smerl...@outlook.com> wrote: >> I've got a slow query.. I'd like to make it faster.. Make add an index? >> Query: >> SELECT >> <> >> FROM gorfs.

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-10 Thread Vitaly Burovoy
//www.postgresql.org/docs/9.2/static/sql-createindex.html > I've rewriten the query as well. Thank you for that! > > Thank you > Lucas >> Date: Sun, 10 Jan 2016 21:23:01 -0800 >> Subject: Re: [GENERAL] Slow Query - PostgreSQL 9.2 >> From: vitaly.buro...@gmail.com >&

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-10 Thread Vitaly Burovoy
www.postgresql.org/docs/9.2/static/sql-createindex.html >> >> > I've rewriten the query as well. Thank you for that! >> > >> > Thank you >> > Lucas >> >> >> Date: Sun, 10 Jan 2016 21:23:01 -0800 >> >> Subject: Re: [GENERAL]

Re: [GENERAL] Slow Query - PostgreSQL 9.2

2016-01-10 Thread Vitaly Burovoy
;> >> >> (f.last_changed >> >> >> >> + >> >> >> >> '24 >> >> >> >> months' :: INTERVAL)) LIMIT 100; >> >> >> > >> >> >> >> <> >> >> >> >> "Tot

Re: [GENERAL] Efficiently selecting single row from a select with window functions row_number, lag and lead

2016-01-05 Thread Vitaly Burovoy
to filter or group rows after the window calculations are performed, you can use a sub-select." Unfortunately it is impossible to give an access to window function to rows not selected by a current query. -- Best regards, Vitaly Burovoy -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general