Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 7:23 PM Adrian Klaver wrote: > "Once restored, it is wise to run ANALYZE on each restored table so the > optimizer has useful statistics; see Section 24.1.3 and Section 24.1.6 > for more information." > > So is there some other step in the process that occurs after the res

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 5:51 PM Adrian Klaver wrote: > Usually what is seen here is the opposite, that tables are restored and > ANALYZE is not run and performance on the subsequent queries is poor due > to lack of current statistics. > > What is the restore process? > For these specific legacy

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 4:50 PM Adrian Klaver wrote: > Smaller hammer: > > > https://www.postgresql.org/docs/11/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS > > "autovacuum_enabled, toast.autovacuum_enabled (boolean)" > > which can be done by ALTER TABLE also: > > https://www.postgresq

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 4:31 PM Adrian Klaver wrote: > Hmm, are there triggers on wss_entries that are UPDATEing/DELETEing > entries elsewhere? > No, that table is pretty much stand-alone. What we're seeing here is most likely caused by the initial copy of the legacy db tables. This happens wh

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 9:22 AM Adrian Klaver wrote: > Can we see the actual function/query? > > Also the schema of the table(s) involved? > Of course. This was added to pull some data from legacy db tables into something we could query while converting the process that populates the legacy db.

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
On Mon, Sep 23, 2019 at 8:57 AM Tom Lane wrote: > Maybe check for waiting on a lock? > It'd be useful to look in pg_stat_activity and/or top(1) while the > initial query is running, to see if it seems to be eating CPU or > is blocked on some condition. > I think this will provide information tha

Re: postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-23 Thread Corey Taylor
> > First thing I'd look at is whether it's the same execution environment > in both cases, eg same search_path. > As far as I can tell, it's the same execution environment, same search_path and same user. I found after testing other situations, that the psql command would always finish as expect

postgres 9.6: insert into select finishes only in pgadmin not psql

2019-09-18 Thread Corey Taylor
If this is a common question or an article exists, please let me know. I couldn't find anything specific about it in stack overflow questions or postgres/psql documentation. This is in PostgreSQL 9.6. I am trying to figure out how to debug an issue where a function 'import_wss' called through pg

Re: Ideas to deal with table corruption

2018-01-06 Thread Corey Taylor
On Sat, Jan 6, 2018 at 12:30 PM, Melvin Davidson wrote: > > *Don't forget to create indexes on the FK's in the table they reference!* > > > *Also, it would be nice to know the PostgreSQL version and O/S.* > Is it possible for an index to not exist on those columns? https://www.postgresql.org/d

Re: Array of foreign key

2017-12-24 Thread Corey Taylor
On Sun, Dec 24, 2017 at 1:11 AM, Daevor The Devoted wrote: > > Le 23 déc. 2017 20:25, "Peter J. Holzer" a écrit : > > I think the OP wants something like this: > > create table features ( > id serial primary key, > name varchar not null > ); > > create table products ( > id serial pr

Re: PostgreSQL needs percentage function

2017-12-18 Thread Corey Taylor
On Mon, Dec 18, 2017 at 11:01 AM, David G. Johnston < david.g.johns...@gmail.com> wrote: > ​Do you mean: > > SELECT id, val, val / (sum(val) OVER ()) > FROM vals;​ > You could end up with a percentage > 100 or divide by 0 with that if the values are not in a proper range. I don't know if that w

Re: Converting timestamp to timestamptz without rewriting tables

2017-12-18 Thread Corey Taylor
On Mon, Dec 18, 2017 at 2:18 AM, Tom Dunstan wrote: > >> >> A timestamptz stores everything as UTC and the value is converted to the session time zone upon retrieval. > > > Which is exactly what we want. If a random person can interject here, I believe what Tom Dunstan is asking about here is the

Re: How to see index was rejected for seq scan?

2017-12-16 Thread Corey Taylor
> But for simple queries, you might get some insight if you set > enable_seqscan to off. Then the planner will give you an index-using > plan if it is at all possible. Then you can compare the costs. If the > planner still gives you a sequential scan, then the index was not > applicable for othe

How to see index was rejected for seq scan?

2017-12-16 Thread Corey Taylor
This isn't meant to be a question about improving a slow query or determining that the planner was wrong. It seems like a simple and obvious answer, but I would love to know if there is any documentation you can point me to read on this. Essentially, if an index was deemed not to save cost during