Re: Join help, please

2020-03-18 Thread Michael Lewis
On Wed, Mar 18, 2020, 12:55 PM Michael Lewis wrote: > work_type.work_type_key = work_type.work_type_key > > You've done a cross join. > You meant to do permitted_work.work_type_key = work_type.work_type_key I expect >

Re: PostgreSQL 10 not archiving some WAL files

2020-03-18 Thread Michael Paquier
of that. This would mean that we are either missing the generation of some .ready file, or that some .done file gets generated when they should not in archive_status/. What kind of server shutdown are you doing? Immediate so as recovery happens at the follow-up startup. Or is that a

Re: RPMs from postgresql.org break CentOS/RHEL RPMs

2020-03-19 Thread Michael Paquier
6a367c382d0a3595238eff2e777222dbc91911b author: Tom Lane date: Thu, 10 Oct 2019 14:24:56 -0400 Put back pqsignal() as an exported libpq symbol. Here is the thread of the discussion: https://www.postgresql.org/message-id/e1g5vmt-0003k1...@gemulon.postgresql.org -- Michael signature.asc Description: PGP signature

Re: Fwd: PG12 autovac issues

2020-03-19 Thread Michael Lewis
On Thu, Mar 19, 2020 at 9:31 AM Justin King wrote: > On Wed, Mar 18, 2020 at 1:40 PM Michael Lewis wrote: > > > > Do you have default fillfactor set on this table? If not, I would wonder > if reducing it to 50% or even 20% would allow many more HOT updates that > would redu

Re: Could postgres12 support millions of sequences? (like 10 million)

2020-03-19 Thread Michael Lewis
On Thu, Mar 19, 2020, 5:48 PM David G. Johnston wrote: > However, one other consideration with sequences: do you care that > PostgreSQL will cache/pin (i.e., no release) every single sequence you > touch for the lifetime of the session? (I do not think DISCARD matters here > but I'm just guessing

Re: PG12 autovac issues

2020-03-20 Thread Michael Lewis
> > We haven't isolated *which* table it is blocked on (assuming it is), > but all autovac's cease running until we manually intervene. > > When we get into this state again, is there some other information > (other than what is in pg_stat_statement or pg_stat_activity) that > would be useful for f

Re: Passwordcheck configuration

2020-03-22 Thread Michael Paquier
swordcheck_extra > (I seem to recall some recent discussion about deprecating/removing > passwordcheck altogether, but I can't find it right now.) This was mentioned last here if I recall correctly: https://www.postgresql.org/message-id/ac785d69-41ec-4d0a-ac37-1f9ff55c9...@amazon.com

Re: Runtime partition pruning

2020-03-23 Thread Michael Lewis
> > select * from test where id between client_id-10 and client_id+10 and > client_id=?; > > does not (it scans all partitions in parallel) . > Is it expected? > Yes. But the below would work fine I expect since the planner would know a constant range for id. I would be very surprised if the opti

Re: PG12 autovac issues

2020-03-23 Thread Michael Paquier
bench. I'm not sure >> if we'll be able to catch the 1h45 interval when the system stays alive >> after the issue though. > > Could you just script something to stop the benchmark once the disk is > 90% full or so? Hmm. I think that this one is possible still tricky. There are some alarms in place in this system. > Did you see any errors / fatals around the time autovacuum stopped > working? Before going rogue (we are not sure if autovacuum didn't launch any workers or if the workers were spawned and exited early as we did not capture any worker information in pg_stat_activity), we saw a bunch of aggressive wraparound jobs. Even after that, we have traces in the logs of one autovacuum analyze happening at equal interval of time (17 minutes) on one single table, which is... Er... uncommon to say the least. -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-23 Thread Michael Paquier
On Mon, Mar 23, 2020 at 10:40:39PM -0700, Andres Freund wrote: > On 2020-03-24 14:26:06 +0900, Michael Paquier wrote: >> Nothing really fancy: >> - autovacuum_vacuum_cost_delay to 2ms (default of v12, but we used it >> in v11 as well). >> - autovacuum_naptime = 15s >

Re: PG 12: Partitioning across a FDW?

2020-03-25 Thread Michael Lewis
Chris, Does it actually need to be a different server and database, or would it be possible to have another storage device added to your existing database and make use of tablespaces to accomplish pseudo-archive of older partitions? Just a thought. >

Re: PG12 autovac issues

2020-03-25 Thread Michael Paquier
ch are mentioned in the logs of the type "skipping redundant vacuum to prevent of table"? > Let me know if there's anything else useful I can provide. Thanks! -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-25 Thread Michael Paquier
ually what I was thinking yesterday. In heap_vacuum_rel(), xidFullScanLimit may be calculated right, but an incorrect value of rd_rel->relminmxid or rd_rel->relfrozenxid could lead to a job to become not aggressive. It should be actually easy enough to check that. -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-26 Thread Michael Paquier
hose anti-wraparound and non-aggressive jobs (this looks like a relcache issue with the so-said catalogs). -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-28 Thread Michael Paquier
wasn't the only one seeing the issue! Yes. We have been able to confirm that 2aa6e33 is a direct cause of your problem. -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-28 Thread Michael Paquier
ons with the revert though, this will address the problem reported by Justin. -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-29 Thread Michael Paquier
e begun on -hackers a couple of days ago. -- Michael signature.asc Description: PGP signature

Re: PG12 autovac issues

2020-03-30 Thread Michael Paquier
On Sat, Mar 28, 2020 at 05:53:59PM +0900, Michael Paquier wrote: > And I'll follow up there with anything new I find. Please let me know > if there are any objections with the revert though, this will address > the problem reported by Justin. Okay. Done with this part now as of

Re: Out of memory in big transactions after upgrade to 12.2

2020-04-03 Thread Michael Lewis
If you didn't turn it off, you have parallel workers on by default with v12. If work_mem is set high, memory use may be much higher as each node in a complex plan could end up executing in parallel. Also, do you use a connection pooler such as pgbouncer or pgpool? What is max_connections set to?

Re: How to prevent master server crash if hot standby stops

2020-04-06 Thread Michael Paquier
tgres. There are however multiple ways to solve this problem, like a background worker (for the slot monitoring as well as optionally killing and/or dropping), a simple cron job or even check_postgres. -- Michael signature.asc Description: PGP signature

Re: Logical replication

2020-04-06 Thread Michael Lewis
There is nothing native to compute this. This was asked a month or so ago. The best the poster came up with was a regular query on master DB which updates a timestamptz field. Assuming master and slave have clocks in sync, it is simple to compute the lag from that. >

Re: Using of --data-checksums

2020-04-07 Thread Michael Paquier
lled with most of the hot data). -- Michael signature.asc Description: PGP signature

Re: Using of --data-checksums

2020-04-11 Thread Michael Paquier
there is also a version on out of core for older versions of Postgres: https://github.com/credativ/pg_checksums. On apt-based distributions like Debian, this stuff is under the package postgresql-12-pg-checksums. -- Michael signature.asc Description: PGP signature

Re: Using of --data-checksums

2020-04-12 Thread Michael Paquier
than it is, no? There is a copy of the file so we may be able to do a block-to-block copy and update of the checksum, but you cannot do that with the --link mode. -- Michael signature.asc Description: PGP signature

Re: GENERATED STORED columns and table rewrites?

2020-04-15 Thread Michael Lewis
Yes, the system will do a full table rewrite to compute the value and store it. Unfortunately, I believe it is an access exclusive lock during that entire time.

Re: pg_restore: could not close data file: Success

2020-04-15 Thread Michael Paquier
n lclContext or equivalent as that's an important piece of the error message. -- Michael signature.asc Description: PGP signature

Re: Recursive Queries

2020-04-16 Thread Michael Lewis
You don't want recursion, you want pivot table (Excel) behavior to reformat rows into columns. The easiest way to get this data in its raw form would be to group by date and hour of day and compute the count. If you have the option to add extensions in your environment, then you should be able to

Re: possibilities for SQL optimization

2020-04-16 Thread Michael Lewis
> > My other thought was to range partition by pixelID + brin index. >>> I would expect brin index to be INSTEAD of partitioning. You didn't share buffer hits, which I expect were 100% on the subsequent explain analyze runs, but the index scan may still be faster if the planner knows it only n

Re: Using of --data-checksums

2020-04-16 Thread Michael Paquier
the error message provided is clear. > This was in part what led to that long blog article I wrote about > checksums, and it's why enabling checksums was happiness hint #1 until I > broke them into categories. Reference? ;p -- Michael signature.asc Description: PGP signature

Re: how to slow down parts of Pg

2020-04-21 Thread Michael Lewis
You say 12.2 is in testing but what are you using now? Have you tuned configs much? Would you be able to implement partitioning such that your deletes become truncates or simply a detaching of the old partition? Generally if you are doing a vacuum full, you perhaps need to tune autovacuum to be mor

Re: how to slow down parts of Pg

2020-04-21 Thread Michael Loftis
drbdsetup allows you to control the sync rates. On Tue, Apr 21, 2020 at 14:30 Kevin Brannen wrote: > I have an unusual need: I need Pg to slow down. I know, we all want our > DB to go faster, but in this case it's speed is working against me in 1 > area. > > > > We have systems that are geo-red

Re: how to slow down parts of Pg

2020-04-21 Thread Michael Loftis
On Tue, Apr 21, 2020 at 15:05 Kevin Brannen wrote: > *From:* Michael Lewis > > > You say 12.2 is in testing but what are you using now? Have you tuned > configs much? Would you be able to implement partitioning such that your > deletes become truncates or simply a detaching of

Re: how to slow down parts of Pg

2020-04-21 Thread Michael Lewis
Reviewing pg_stat_user_tables will give you an idea of how often autovacuum is cleaning up those tables that "need" that vacuum full on a quarterly basis. You can tune individual tables to have a lower threshold ratio of dead tuples so the system isn't waiting until you have 20% dead rows before va

Re: pg11: Query using index, but only for half the partitions

2020-04-23 Thread Michael Lewis
What do the statistics look like for an example table that the index I used vs not? Is ((instance_id)::text = 'test01'::text) rare for the tables where an index scan is happening and common for the tables where a sequential scan is chosen? How many rows in these tables generally?

Re: relationship of backend_start, query_start, state_change

2020-04-23 Thread Michael Lewis
If you use a connection pooler, this would likely be expected behavior since the connection is getting reused many times. Else, some app is connected and not closing their connection between queries. At least they aren't idle in transaction though.

Re: Can I tell libpq to connect to the primary?

2020-04-24 Thread Michael Paquier
cluster that has just been freshly promoted: when connecting to the server libpq may see the connection as read-only but if the standby gets promoted that could become incorrect. -- Michael signature.asc Description: PGP signature

Re: Abnormal Growth of Index Size - Index Size 3x large than table size.

2020-05-06 Thread Michael Lewis
Indexes larger than the table may be expected if there are many. It may be prudent to check if they are being used in pg_stat_all_indexes. If there are just a few indexes that are becoming bloated quickly, you'd want to ensure your autovacuum settings are tuned more aggressively, and consider lowe

Re: Postgres 11.6-2 to 11.7 worth the upgrade?

2020-05-07 Thread Michael Lewis
https://www.postgresql.org/docs/release/11.7/ It doesn't seem like it. Always best to run the most current minor version though.

Re: wal_sender_timeout default

2020-05-07 Thread Michael Lewis
https://www.postgresql.org/docs/11/runtime-config-replication.html >

Re: Abnormal Growth of Index Size - Index Size 3x large than table size.

2020-05-07 Thread Michael Lewis
On Thu, May 7, 2020 at 8:50 AM Ashish Chugh < ashish.ch...@lavainternational.in> wrote > To improve performance and release index space from database, We are > running FULL Vacuum on monthly basis. > > On PostgreSQL website it is not recommended to run FULL Vacuum on > Production Database and this

Re: AutoVacuum and growing transaction XID's

2020-05-07 Thread Michael Lewis
It is trying to do a vacuum freeze. Do you have autovacuum turned off? Any settings changed from default related to autovacuum? https://www.postgresql.org/docs/9.6/routine-vacuuming.html Read 24.1.5. Preventing Transaction ID Wraparound Failures These may also be of help- https://info.crunchydata

Re: AutoVacuum and growing transaction XID's

2020-05-08 Thread Michael Lewis
autovacuum_naptime being only 5 seconds seems too frequent. A lock_timeout might be 1-5 seconds depending on your system. Usually, DDL can fail and wait a little time rather than lock the table for minutes and have all reads back up behind the DDL. Given you have autovacuum_vacuum_cost_limit set t

Re: [GENERAL] import .sql file into PostgreSQL database

2020-05-09 Thread Michael Paquier
k here: https://lists.postgresql.org/ -- Michael signature.asc Description: PGP signature

Re: Hash partitioning, what function is used to compute the hash?

2020-05-11 Thread Michael Lewis
The documentation shows it is just a modulus operation. If you partition on object_key % 3 then you will create three partitions for remainder values 0-2 for instance. Afaik, hash partition doesn't have real world expected use cases just yet. List or range is probably what you want to use.

Re: Hash partitioning, what function is used to compute the hash?

2020-05-12 Thread Michael Lewis
On Mon, May 11, 2020 at 3:13 PM Alvaro Herrera wrote: > On 2020-May-11, Michael Lewis wrote: > > > Afaik, hash partition doesn't have real world expected use cases just > yet. > > I don't think I agree with this assertion. > I didn't mean to be critical a

Re: [EXTERNAL] Re: PostgreSQL-12 replication failover, pg_rewind fails

2020-05-13 Thread Michael Paquier
is set in the target cluster's configuration. This way, you can fetch missing WAL segments from archives during the rewind operation without the need to rely on wal_keep_segments or such. -- Michael signature.asc Description: PGP signature

Re: Reuse an existing slot with a new initdb

2020-05-13 Thread Michael Paquier
ur configuration, we may be able to help, but it is not really possible to help out without more details. For example, the first sentence of your first email mentions the use of replication slots. You may want to explain better where the slots are used, how they get either dropped and/or recre

Re: Practical usage of large objects.

2020-05-13 Thread Michael Paquier
can be much cheaper than a toasted field, as the latter would update/read the value as a whole. -- Michael signature.asc Description: PGP signature

Re: Check what has been done for a uncommitted prepared transaction

2020-05-14 Thread Michael Paquier
mm select generate_series(1, 1000); > INSERT 0 1000 > > I can get the log for "prepared command" only, but nothing was found for > the insert statement. what should I do? Because in your previous sequence you inserted the data after preparing the transaction and they are par

Re: vacuumdb --jobs deadlock: how to avoid pg_catalog ?

2020-05-14 Thread Michael Lewis
On Thu, May 14, 2020 at 2:20 PM Eduard Rozenberg wrote: > I did verify postgresql.conf has always been properly configured re: > autovacuum: 'autovacuum = on'and 'track_counts = on' > This may be insufficient to keep up if you have large tables. The default scale factor allows for 20% of the ro

Re: Bug on version 12 ?

2020-05-15 Thread Michael Lewis
Just wonder, have you compared these on the two servers? select * from pg_settings where name = 'DateStyle';

Re: Inherited an 18TB DB & need to backup

2020-05-15 Thread Michael Nolan
On Fri, May 15, 2020 at 12:51 PM Ravi Krishna wrote: > > Why should the backup land in S3, and not local somewhere? > Any good reason why one should pay for the additional storage and transfer > costs? > > Good question. The key point in my statement was "db of this size". > > The problem with lo

Re: Removing Last field from CSV string

2020-05-16 Thread Michael Nolan
On Sat, May 16, 2020 at 10:19 AM Alex Magnum wrote: > Hi, > > I have a string that I want to cut to 60 char and then remove the last > field and comma. > > substring('Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class > X,Class XI,Class IX,Class XII',1,60); > > substring | Class V,Class

Re: A limit clause can cause a poor index choice

2020-05-19 Thread Michael Lewis
What does pg_stats say about column customer_id? Specifically, how many ndistinct, and what is the sum of the most common values? If you have 1000 distinct customer_id values, and the (default 100) most common values only cover 2% of the total rows, then the optimizer will assume that any given cus

Re: How to recover from compressed wal archieve in windows

2020-05-20 Thread Michael Paquier
a check on the size, which would fail if the WAL segment is still compressed. This logic is in RestoreArchivedFile() in xlogarchive.c. -- Michael signature.asc Description: PGP signature

Re: How to recover from compressed wal archieve in windows

2020-05-20 Thread Michael Paquier
if the page is compressed with pglz or not. Then WAL replay looks at those flags, and determines what to do by itself when the page image is needed. -- Michael signature.asc Description: PGP signature

Re: Table partitioning for cloud service?

2020-05-21 Thread Michael Lewis
On Thu, May 21, 2020 at 11:41 AM Adam Brusselback wrote: > As an optimization I just worked on for my database earlier this week, I > decided to logically replicate that table from my main authentication > database into a each cluster, and I replaced all references to the FDW for > read-only quer

Re: Strategy for materialisation and centralisation of data

2020-05-21 Thread Michael Stephenson
You might find Materialize interesting: https://materialize.io/ https://youtu.be/zWSdkGq1XWk On Thu, May 21, 2020 at 10:36 AM Rory Campbell-Lange < r...@campbell-lange.net> wrote: > We have quite a few databases of type a and many of type b in a cluster. > Both a and b types are fairly complex

Re: Request to help on GIS Query improvement suggestion.

2020-05-22 Thread Michael Lewis
Your indexes and operators are not compatible. You have added a btree index on md5 function result and are not using md5 in your query, and also using LIKE operator not one of the supported ones. I believe it might use a btree operator (plain value, not md5 result) if you are always searching for "

Re: Suggestion to improve query performance of data validation in proc.

2020-05-22 Thread Michael Lewis
On Fri, May 22, 2020 at 2:09 AM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Friday, May 22, 2020, postgann2020 s wrote: > > >> >> We are looking for a better query than "*SELECT 1 FROM >> schema.table_name WHERE column1=structure_id1*" this query for data >> validation. >> > If

Re: Inaccurate (sometimes wildly so) row estimates for simple join

2020-05-22 Thread Michael Lewis
On Fri, May 22, 2020 at 7:27 AM Greg Nolle wrote: > The crux seems to be that test_b does not have an even distribution for > a_id values: it only has records for two of the values in the referenced > table. This is how our real dataset is too and isn’t something we can > really change. > How do

Re: query, probably needs window functions

2020-05-22 Thread Michael Lewis
I believe something like this is what you want. You might be able to do it without a sub-query by comparing the current name value to the lag value and null it out if it's the same. select case when row_number = 1 then id end AS id, case when row_number = 1 then name end as name, phone.number from

Re: Query returns no rows in pg_basebackup cluster

2020-05-24 Thread Michael Paquier
r without any platform, architecture or even not-too-many major version constraints, there is also logical replication available since v10. -- Michael signature.asc Description: PGP signature

Re: Query returns no rows in pg_basebackup cluster

2020-05-24 Thread Michael Paquier
hat can become useful: https://www.postgresql.org/docs/devel/logical-replication.html -- Michael signature.asc Description: PGP signature

Re: lib/libecpg.so.6.11 && valgrind

2020-05-30 Thread Michael Paquier
not show me any leaks similar to what you have here after testing on HEAD and REL_11_STABLE. It is likely possible that we are missing something though, so could you send a test case to reproduce what you are seeing? -- Michael signature.asc Description: PGP signature

Re: Oracle vs. PostgreSQL - a comment

2020-06-02 Thread Michael Nolan
I spent about 10 years as an Oracle DBA (back around Oracle 7 and 8) and the last 20 or so years doing PostgreSQL. My initial impressions were that Oracle did a better job providing tools and options that users and DBAs need and PostgreSQL was pretty much roll-your-own. Things like being able to

A parsing question

2020-06-03 Thread Michael Nolan
Recently I was typing in a query in PG 10.4. What I MEANT to type was: Where xyz >= 2400 What I actually typed was: Where xyz >- 2400 The latter was interpreted as 'where xyz > -2400', but I'm wondering if it shouldn't have thrown an error on an unrecognized operator '>-' Thoughts? -- Mike N

Re: Oracle vs. PostgreSQL - a comment on Mysql

2020-06-03 Thread Michael Nolan
On Wed, Jun 3, 2020 at 5:21 PM Martin Mueller < martinmuel...@northwestern.edu> wrote: > On the topic of what other databases do better: I much prefer Postgres to > Mysql because it has better string functions and better as well as very > courteous error messages. > Martin, I definitely sympathiz

Re: Index no longer being used, destroying and recreating it restores use.

2020-06-05 Thread Michael Lewis
Those row estimates are pretty far off. Standard indexes and partial indexes don't get custom statistics created on them, but functional indexes do. I wonder if a small function needs_backup( shouldbebackedup, backupperformed ) and an index created on that function would nicely alleviate the pain.

Re: Logical replication - ERROR: could not send data to WAL stream: cannot allocate memory for input buffer

2020-06-07 Thread Michael Paquier
able to detect any leaks. And I am afraid that it is hard to act on this report without more information. -- Michael signature.asc Description: PGP signature

Re: Index no longer being used, destroying and recreating it restores use.

2020-06-08 Thread Michael Lewis
On Mon, Jun 8, 2020 at 2:34 PM Koen De Groote wrote: > So, this query: > > select * from item where shouldbebackedup=true and > itemCreated<='2020-06-05 00:00:00.000' and backupperformed=false order by > filepath asc, id asc limit 100 offset 10400; > > Was made into a function: > > create or repl

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Michael Lewis
On Tue, Jun 9, 2020 at 12:34 PM Sebastian Dressler wrote: > - Add an index on top of the whole PK > - Add indexes onto other columns trying to help the JOIN > - Add additional statistics on two related columns > > Another idea I had was to make use of generated columns and hash the PKs > together

Re: Postgres server 12.2 crash with process exited abnormally and possibly corrupted shared memory

2020-06-09 Thread Michael Lewis
On Tue, Jun 9, 2020 at 8:35 AM Ishan Joshi wrote: > I have using postgresql server v12.2 on CentOS Linux release 7.3.1611 > (Core). > > > > My application is working fine with non partition tables but recently we > are trying to adopt partition table on few of application tables. > > So we have

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Michael Lewis
> > the join selectivity functions have yet to learn about extended statistics. > That is very interesting to me. So, extended statistics would help to properly estimate the result set coming out of a single table when comparing each of those columns to one or many values, but not when joining up

Re: Logical replication stuck in catchup state

2020-06-09 Thread Michael Lewis
I don't know if it would be relevant to this problem, but you are missing almost 1 full year of bug fixes. 11.4 was released on 20 June last year. Upgrading minor versions asap is recommended. I do see this in the release notes from 11.8 last month ( https://www.postgresql.org/docs/release/11.8/)-

Re: Postgres server 12.2 crash with process exited abnormally and possibly corrupted shared memory

2020-06-10 Thread Michael Lewis
On Wed, Jun 10, 2020 at 12:05 AM Ishan Joshi wrote: > How many rows did these tables have before partitioning? à We starts > test with 0 rows in partition table. > Partitions are far from free and pruning is great but not guaranteed. How many total rows do you currently have or foresee hav

Re: Parallel safety of contrib extensions

2020-06-11 Thread Michael Paquier
ven simpler now that we just need update scripts when bumping a module's version (those named foo--1.0--1.1.sql and not foo--1.1.sql). Here is the related documentation: https://www.postgresql.org/docs/devel/extend-extensions.html#id-1.8.3.20.15 -- Michael signature.asc Description: PGP signature

Re: Index no longer being used, destroying and recreating it restores use.

2020-06-15 Thread Michael Lewis
On Tue, Jun 9, 2020 at 6:24 AM Koen De Groote wrote: > Right. In that case, the function I ended up with is this: > > create or replace function still_needs_backup(bool, bool) > returns BOOLEAN as $$ > BEGIN > PERFORM 1 from item where shouldbebackedup=$1 and backupperformed=$2; > IF FO

Re: pg_repack: WARNING: relation must have a primary key or not-null unique keys

2020-06-16 Thread Michael Lewis
On Tue, Jun 16, 2020, 4:52 AM Eugene Pazhitnov wrote: > xbox=> \d herostat >Table "public.herostat" > Indexes: > "herostat_pkey" PRIMARY KEY, btree (xuid, titleid, heroid) INCLUDE > (valfloat) > > WARNING: relation "public.herostat" must have a primary key or not-null > un

Re: autovacuum failing on pg_largeobject and disk usage of the pg_largeobject growing unchecked

2020-06-16 Thread Michael Lewis
On Tue, Jun 16, 2020 at 10:01 AM Jim Hurne wrote: > Other than the increasing elapsed times for the autovacuum, we don't see > any other indication in the logs of a problem (no error messages, etc). > > We're currently using PostgreSQL version 10.10. Our service is JVM-based > and we're using the

Re: autovacuum failing on pg_largeobject and disk usage of the pg_largeobject growing unchecked

2020-06-16 Thread Michael Lewis
On Tue, Jun 16, 2020 at 1:45 PM Jim Hurne wrote: > Thanks Michael, > > Here are our current autovacuum settings: > > autovacuum | on > autovacuum_analyze_scale_factor | 0.1 > autovacuum_analyze_threshold| 50 > a

Re: Importing a Large .ndjson file

2020-06-18 Thread Michael Lewis
> > I spoke too soon. While this worked fine when there were no indexes > and finished within 10 minutes, with GIN index on the jsonb column, it > is taking hours and still not completing. > It is always recommended to create indexes AFTER loading data. Sometimes it can be faster to drop all index

Re: Parallel safety of contrib extensions

2020-06-18 Thread Michael Paquier
CA3FD9B0%40AM5PR0901MB1587.eurprd09.prod.outlook.com -- Michael signature.asc Description: PGP signature

Re: DISTINCT on jsonb fields and Indexes

2020-06-22 Thread Michael Lewis
On Sun, Jun 21, 2020 at 10:43 PM Sankar P wrote: > I have a table with the schema: > > CREATE TABLE fluent (id BIGSERIAL, record JSONB); > > Then I created a couple of indexes: > 1) CREATE INDEX idx_records ON fluent USING GIN (record); > What about using non-default jsonb_path_ops? > 2) CREA

Re: DISTINCT on jsonb fields and Indexes

2020-06-22 Thread Michael Lewis
> > In the example of "select distinct expression", the planner will never > notice > that that expression has anything to do with an index. > Thanks for that explanation. I assume re-writing as a 'group by' would have no bearing on that planner decision.

Re: autovacuum failing on pg_largeobject and disk usage of the pg_largeobject growing unchecked

2020-06-22 Thread Michael Lewis
On Tue, Jun 16, 2020 at 2:41 PM Michael Lewis wrote: > On Tue, Jun 16, 2020 at 1:45 PM Jim Hurne wrote: > >> Thanks Michael, >> >> Here are our current autovacuum settings: >> >> autovacuum | on >>

Re: n_distinct off by a factor of 1000

2020-06-23 Thread Michael Lewis
> > > > On 23/06/2020 14:42, Klaudie Willis wrote: > > > > > > > I got my first hint of why this problem occurs when I looked at the > > > > statistics. For the column in question, "instrument_ref" the > > > > statistics claimed it to be: > > > > The default_statistics_target=500, and analyze has

Re: UPDATE on 20 Million Records Transaction or not?

2020-06-23 Thread Michael Lewis
> > >Are you updating *every* row in the table? >> >> No I am using an update like so: UPDATE members SET regdate='2038-01-18' >> WHERE regdate='2020-07-07' >> >> DB=# select count(*) from members where regdate = '2020-07-07'; >> >> count >> >> -- >> >> 17333090 >> >> (1 row) >> >> Just u

Re: autovacuum failing on pg_largeobject and disk usage of the pg_largeobject growing unchecked

2020-06-23 Thread Michael Lewis
On Tue, Jun 23, 2020 at 2:34 PM Jim Hurne wrote: > Sure! Below are more of the details from the same set of logs. Looking at > them myself, I see that there is always some percentage of tuples that are > dead but are not yet removable. And that number increases on every vacuum, > which might expl

Re: Persistent Connections

2020-06-23 Thread Michael Lewis
On Tue, Jun 23, 2020 at 2:29 PM Bee.Lists wrote: > I have an issue with a server (v10) that’s seeing increasing connections > until it’s maxxed-out. > > max_connections for my 4-core server is set to 12. > > I’ve installed pg_stat_activity and pg_stat_statements. > Do you see anything in pg_stat

Re: SQL delete and update at the same time

2020-06-24 Thread Michael Lewis
> > But how can I set the edited vale = 1 on the objects (line segments) that > are not deleted (in the current buffer) at the same time so it won’t be > deleted in the next run with an adjacent buffer? > You might want to create a temporary table to hold unique identifiers of all records that you

Re: n_distinct off by a factor of 1000

2020-06-24 Thread Michael Lewis
On Wed, Jun 24, 2020, 2:35 PM Peter J. Holzer wrote: > Yes, estimating the number of distinct values from a relatively small > sample is hard when you don't know the underlying distribution. It might > be possible to analyze the sample to find the distribution and get a > better estimate. But I'm

Re: n_distinct off by a factor of 1000

2020-06-25 Thread Michael Lewis
On Thu, Jun 25, 2020 at 7:27 AM Pavel Luzanov wrote: > I have tried to increase the statistics target to 5000, and it helps, but > it reduces the error to 100X. Still crazy high. > > > As far as I know, increasing default_statistics_target will not help. [1] > > I have considered these fixes: >

Re: SQL delete and update at the same time

2020-06-25 Thread Michael Lewis
Sorry, I don't know much about postgis at all. I assume you meant to have THEN 1 in your update statement as well. I notice b.fid=l.fid and NOT b.fid=l.fid in the two clauses. How about separate update statements? UPDATE linesegments l set edited = 1 WHERE l.gid IN (SELECT li.gid FROM linesegmen

Re: Logical Replication Issue

2020-06-30 Thread Michael Lewis
Per the release notes, there are some enhancements to logical replication that came after 11.5 like 11.8 particularly related to replication identity full. Do you have a primary key or unique index that is being used for the replication identity?

Re: Different results from identical matviews

2020-07-02 Thread Michael Lewis
Is now() computed at the time the view is defined and not at refresh? If this were a function, I would be more suspicious of that but a plain view, surely not. I hope. >

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Michael Lewis
On Mon, Jul 6, 2020 at 5:37 AM Robins Tharakan wrote: > This need came up while reviewing generated SQL, where the need was to > return true when > at least one of two lists had a row. > Generated SQL... yep. That will happen. Manual SQL may be more work, but often has significant reward. If yo

Re: Is postgres able to share sorts required by common partition window functions?

2020-07-06 Thread Michael Lewis
Does this give the same result and do the optimization you want? select c1, min(c2) AS c2, min(c3) AS c3, min(c4) AS c4 from t group by c1; >

Re: Is postgres able to share sorts required by common partition window functions?

2020-07-06 Thread Michael Lewis
Distinct is a great way to get quick results when writing quick & dirty queries, but I rarely have them perform better than a re-write that avoids the need. It collects a ton of results, orders them, and throws away duplicates in the process. I don't love the idea of that extra work. Did you say yo

Re: Is postgres able to share sorts required by common partition window functions?

2020-07-07 Thread Michael Lewis
On Monday, July 6, 2020, Michael Lewis wrote: > Did you say you have an index on c1? > [...] > I don't know the data, but I assume there may be many rows with the same > c1 value, so then you would likely benefit from getting that distinct set > first like below as your

<    1   2   3   4   5   6   7   8   9   >