Re: planner chooses incremental but not the best one

2024-02-15 Thread Tomas Vondra
On 2/15/24 07:50, Andrei Lepikhov wrote: > On 18/12/2023 19:53, Tomas Vondra wrote: >> On 12/18/23 11:40, Richard Guo wrote: >> The challenge is where to get usable information about correlation >> between columns. I only have a couple very rought ideas of what might >&

Re: logical decoding and replication of sequences, take 2

2024-02-14 Thread Tomas Vondra
On 2/13/24 17:37, Robert Haas wrote: > On Sun, Jan 28, 2024 at 1:07 AM Tomas Vondra > wrote: >> Right, locks + apply in commit order gives us this guarantee (I can't >> think of a case where it wouldn't be the case). > > I couldn't find any cases of inadequate lock

Re: index prefetching

2024-02-14 Thread Tomas Vondra
de when to kill tuples and unpin the index page (instead of just doing it when moving to the next index page) Maybe that's what you meant by "more sophisticated bookkeeping", ofc. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: index prefetching

2024-02-14 Thread Tomas Vondra
On 2/13/24 20:54, Peter Geoghegan wrote: > On Tue, Feb 13, 2024 at 2:01 PM Tomas Vondra > wrote: >> On 2/7/24 22:48, Melanie Plageman wrote: >> I admit I haven't thought about kill_prior_tuple until you pointed out. >> Yeah, prefetching separates (de-synchronizes) the two

Re: index prefetching

2024-02-13 Thread Tomas Vondra
recently prefetched blocks. As he has said, it > probably makes sense to add something to do this in a lower layer -- > such as in the streaming read API or even in bufmgr.c (maybe in > PrefetchSharedBuffer()). > I agree this should happen in lower layers. I'd probably do this in the streaming read API, because that would define "scope" of the cache (pages prefetched for that read). Doing it in PrefetchSharedBuffer seems like it would do a single cache (for that particular backend). But that's just an initial thought ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: brininsert optimization opportunity

2024-02-13 Thread Tomas Vondra
On 1/8/24 16:51, Alvaro Herrera wrote: > On 2023-Dec-12, Tomas Vondra wrote: > >> I propose we do a much simpler thing instead - allow the cache may be >> initialized / cleaned up repeatedly, and make sure it gets reset at >> convenient place (typically after index_in

Re: Thoughts about NUM_BUFFER_PARTITIONS

2024-02-10 Thread Tomas Vondra
4 partitions it still takes only 38 backends to get 50% chance of a collision. Better, but considering we now have hundreds of cores, not sure if sufficient. (Obviously, we probably want much lower probability of a collision, I only used 50% to illustrate the changes). regards -- Tomas Vond

Re: Statistics Import and Export

2024-02-07 Thread Tomas Vondra
oduce slightly different results on the two versions (causing false mismatches), but perhaps the deparse on source + parse on target + compare nodetrees would work? Haven't tried, though. > Export formats go back to v10. > Do we even want/need to go beyond 12? All earlier versions are EOL. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: scalability bottlenecks with (many) partitions (and more)

2024-01-31 Thread Tomas Vondra
On 1/29/24 16:42, Ronan Dunklau wrote: > Le lundi 29 janvier 2024, 15:59:04 CET Tomas Vondra a écrit : >> I'm not sure work_mem is a good parameter to drive this. It doesn't say >> how much memory we expect the backend to use - it's a per-operation >> limit, so it doesn't w

Re: scalability bottlenecks with (many) partitions (and more)

2024-01-29 Thread Tomas Vondra
On 1/29/24 15:15, Ronan Dunklau wrote: > Le lundi 29 janvier 2024, 13:17:07 CET Tomas Vondra a écrit : >>> Did you try running an strace on the process ? That may give you some >>> hindsights into what malloc is doing. A more sophisticated approach would >>&

Re: scalability bottlenecks with (many) partitions (and more)

2024-01-29 Thread Tomas Vondra
On 1/29/24 09:53, Ronan Dunklau wrote: > Le dimanche 28 janvier 2024, 22:57:02 CET Tomas Vondra a écrit : > > Hi Tomas ! > > I'll comment on glibc-malloc part as I studied that part last year, and > proposed some things here: https://www.postgresql.org/message-id/ &g

Re: logical decoding and replication of sequences, take 2

2024-01-27 Thread Tomas Vondra
On 1/26/24 15:39, Robert Haas wrote: > On Wed, Jan 24, 2024 at 12:46 PM Tomas Vondra > wrote: >> I did try to explain how this works (and why) in a couple places: >> >> 1) the commit message >> 2) reorderbuffer header comment >> 3) ReorderBufferSequenc

Re: index prefetching

2024-01-25 Thread Tomas Vondra
On 1/25/24 11:45, Dilip Kumar wrote: > On Wed, Jan 24, 2024 at 11:43 PM Tomas Vondra > wrote: > >> On 1/22/24 07:35, Konstantin Knizhnik wrote: >>> >>> On 22/01/2024 1:47 am, Tomas Vondra wrote: >>>> h, right. Well, you're right in this case we p

Re: index prefetching

2024-01-24 Thread Tomas Vondra
On 1/22/24 07:35, Konstantin Knizhnik wrote: > > On 22/01/2024 1:47 am, Tomas Vondra wrote: >> h, right. Well, you're right in this case we perhaps could set just one >> of those flags, but the "purpose" of the two places is quite different. >> >>

Re: index prefetching

2024-01-24 Thread Tomas Vondra
On 1/22/24 08:21, Konstantin Knizhnik wrote: > > On 22/01/2024 1:39 am, Tomas Vondra wrote: >>> Why we can prefer covering index  to compound index? I see only two good >>> reasons: >>> 1. Extra columns type do not  have comparison function need for AM. >&g

Re: logical decoding and replication of sequences, take 2

2024-01-24 Thread Tomas Vondra
On 1/23/24 21:47, Robert Haas wrote: > On Thu, Jan 11, 2024 at 11:27 AM Tomas Vondra > wrote: >> 1) desirability: We want a built-in way to handle sequences in logical >> replication. I think everyone agrees this is not a way to do distributed >> sequences in

Re: index prefetching

2024-01-24 Thread Tomas Vondra
On 1/24/24 01:51, Melanie Plageman wrote: > On Tue, Jan 23, 2024 at 12:43 PM Tomas Vondra > wrote: >> >> On 1/19/24 22:43, Melanie Plageman wrote: >> >>> We fill a queue with blocks from TIDs that we fetched from the index. >>> The queue is saved i

Re: index prefetching

2024-01-23 Thread Tomas Vondra
On 1/19/24 22:43, Melanie Plageman wrote: > On Fri, Jan 12, 2024 at 11:42 AM Tomas Vondra > wrote: >> >> On 1/9/24 21:31, Robert Haas wrote: >>> On Thu, Jan 4, 2024 at 9:55 AM Tomas Vondra >>> wrote: >>>> Here's a somewhat reworked versi

Re: index prefetching

2024-01-21 Thread Tomas Vondra
On 1/21/24 20:56, Konstantin Knizhnik wrote: > > On 19/01/2024 2:35 pm, Tomas Vondra wrote: >> >> On 1/19/24 09:34, Konstantin Knizhnik wrote: >>> On 18/01/2024 6:00 pm, Tomas Vondra wrote: >>>> On 1/17/24 09:45, Konstantin Knizhnik wrote: >>>

Re: index prefetching

2024-01-21 Thread Tomas Vondra
On 1/21/24 20:50, Konstantin Knizhnik wrote: > > On 20/01/2024 12:14 am, Tomas Vondra wrote: >> Looks like I was not true, even if it is not index-only scan but index >>> condition involves only index attributes, then heap is not accessed >>> until we find tup

Re: index prefetching

2024-01-19 Thread Tomas Vondra
On 1/19/24 16:19, Konstantin Knizhnik wrote: > > On 18/01/2024 5:57 pm, Tomas Vondra wrote: >> On 1/16/24 21:10, Konstantin Knizhnik wrote: >>> ... >>> >>>> 4. I think that performing prefetch at executor level is really great >>>>> i

Re: index prefetching

2024-01-19 Thread Tomas Vondra
On 1/19/24 09:34, Konstantin Knizhnik wrote: > > On 18/01/2024 6:00 pm, Tomas Vondra wrote: >> On 1/17/24 09:45, Konstantin Knizhnik wrote: >>> I have integrated your prefetch patch in Neon and it actually works! >>> Moreover, I combined it with prefetch of

Re: index prefetching

2024-01-18 Thread Tomas Vondra
es core (as > it is currently done in Neon). > Yeah, I think that's the right solution. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: index prefetching

2024-01-18 Thread Tomas Vondra
case. > That's true, but that's why I started working on this: https://commitfest.postgresql.org/46/4352/ I need to think about how to combine that with the prefetching. The good thing is that both changes require fetching TIDs, not slots. I think the condition can be simply added to the pre

Re: index prefetching

2024-01-16 Thread Tomas Vondra
On 1/16/24 09:13, Konstantin Knizhnik wrote: > Hi, > > On 12/01/2024 6:42 pm, Tomas Vondra wrote: >> Hi, >> >> Here's an improved version of this patch, finishing a lot of the stuff >> that I alluded to earlier - moving the code from indexam.c, renaming a

Re: Custom explain options

2024-01-16 Thread Tomas Vondra
On 1/15/24 21:42, Konstantin Knizhnik wrote: > > On 15/01/2024 5:08 pm, Tomas Vondra wrote: >> >> My patch does not care about prefetching internal index pages. Yes, it's >> a limitation, but my assumption is the internal pages are maybe 0.1% of >> the index, a

Re: Custom explain options

2024-01-15 Thread Tomas Vondra
On 1/15/24 15:22, Konstantin Knizhnik wrote: > > On 14/01/2024 11:47 pm, Tomas Vondra wrote: >> The thing that was not clear to me is who decides what to prefetch, >> which code issues the prefetch requests etc. In the github links you >> shared I see it happ

Re: BRIN indexes vs. SK_SEARCHARRAY (and preprocessing scan keys)

2024-01-14 Thread Tomas Vondra
On 1/14/24 12:18, vignesh C wrote: > On Fri, 14 Jul 2023 at 20:17, Tomas Vondra > wrote: >> >> On 7/9/23 23:44, Tomas Vondra wrote: >>> ... >>>>> Yes, my previous message was mostly about backwards compatibility, and >>>>> this may

Re: Custom explain options

2024-01-14 Thread Tomas Vondra
On 1/13/24 17:13, Konstantin Knizhnik wrote: > > On 13/01/2024 4:51 pm, Tomas Vondra wrote: >> >> On 1/12/24 20:30, Konstantin Knizhnik wrote: >>> On 12/01/2024 7:03 pm, Tomas Vondra wrote: >>>> On 10/21/23 14:16, Konstantin Knizhnik wrote: >>>

Re: Custom explain options

2024-01-13 Thread Tomas Vondra
On 1/12/24 20:30, Konstantin Knizhnik wrote: > > On 12/01/2024 7:03 pm, Tomas Vondra wrote: >> On 10/21/23 14:16, Konstantin Knizhnik wrote: >>> Hi hackers, >>> >>> EXPLAIN statement has a list of options (i.e. ANALYZE, BUFFERS, >>> COST,..

Re: Custom explain options

2024-01-12 Thread Tomas Vondra
ther nodes? I'm asking because I've been working on prefetching for index scans, so I'm wondering if there's a better way to do this, or how to do it in a way that would allow neon to maybe leverage that too. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: index prefetching

2024-01-12 Thread Tomas Vondra
bit wild ideas for the future, others are somewhat "open questions" to be discussed during a review. Anyway, there should be no outright obsolete comments - if there's something I missed, let me know. Now to Robert's message ... On 1/9/24 21:31, Robert Haas wrote: > On Thu, J

Re: Multidimensional Histograms

2024-01-07 Thread Tomas Vondra
stogram has no dependence on B. > Really? I'd expect that to build B buckets, the algorithm repeat some O(M*N) action B-times, roughly. I mean, it needs to pick a dimension by which to split, then do some calculation on the N tuples, etc. Maybe I'm imagining that wrong, though. It's been ag

Re: Multidimensional Histograms

2024-01-07 Thread Tomas Vondra
On 1/7/24 18:26, Andrei Lepikhov wrote: > On 7/1/2024 17:51, Tomas Vondra wrote: >> On 1/7/24 11:22, Andrei Lepikhov wrote: >>> On 7/1/2024 06:54, Tomas Vondra wrote: >>>> It's an interesting are for experiments, no doubt about it. And if you >>>> c

Re: Multidimensional Histograms

2024-01-07 Thread Tomas Vondra
On 1/7/24 11:22, Andrei Lepikhov wrote: > On 7/1/2024 06:54, Tomas Vondra wrote: >> It's an interesting are for experiments, no doubt about it. And if you >> choose to explore it, that's fine. But it's better to be aware it may >> not end with a commit. >> For th

Re: Multidimensional Histograms

2024-01-06 Thread Tomas Vondra
be solved simply by using a different 1-D histogram. I'm not going to reject that outright - but I think the bar you'd need to justify such change is damn high. Pretty much everyone is using the current histograms, which makes it a very sensitive area. You'll need to show that it helps in practice, without hurting causing harm ... It's an interesting are for experiments, no doubt about it. And if you choose to explore it, that's fine. But it's better to be aware it may not end with a commit. For the multi-dimensional case, I propose we first try to experiment with the various algorithms, and figure out what works etc. Maybe implementing them in python or something would be easier than C. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: index prefetching

2024-01-04 Thread Tomas Vondra
[1] https://www.postgresql.org/message-id/CA%2BhUKGJkOiOCa%2Bmag4BF%2BzHo7qo%3Do9CFheB8%3Dg6uT5TUm2gkvA%40mail.gmail.com -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL CompanyFrom 74bd0d6b70fa8ca3a1b26196de6b7a9cc670ac9b Mon Sep 17 00:00:00 2001 From: Tomas Vondra

Re: pg_class.reltuples of brin indexes

2023-12-30 Thread Tomas Vondra
or if it has some practical impact. And I'm not sure there's a good way to improve this, except for some basic guesswork. For BRIN I can imagine simply calculating the number of page ranges (relpages / pages_per_range), but no idea about GIN. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Why do parallel scans require syncscans (but not really)?

2023-12-30 Thread Tomas Vondra
low_sync parameters too. Is there a reason why all parallel plans should / must be synchronized? Well, in fact they are not *required* because if I set synchronize_seqscans=off this makes the initscan() to remove the SO_ALLOW_SYNC ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com Th

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-30 Thread Tomas Vondra
nbuild()? Then it'd make sense to have something like _bt_parallel_heapscan ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Fix Brin Private Spool Initialization (src/backend/access/brin/brin.c)

2023-12-30 Thread Tomas Vondra
or the report. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Statistics Import and Export

2023-12-29 Thread Tomas Vondra
f the original data, a CountMin sketch, or something like that. Yes, I don't think people do that often, but as long as the type also implements custom selectivity functions for the operators, I think this would work. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Fix Brin Private Spool Initialization (src/backend/access/brin/brin.c)

2023-12-29 Thread Tomas Vondra
On 12/29/23 14:53, Ranier Vilela wrote: > > > Em sex., 29 de dez. de 2023 às 10:33, Tomas Vondra > mailto:tomas.von...@enterprisedb.com>> > escreveu: > > > > On 12/29/23 12:53, Ranier Vilela wrote: > > Em qui., 28

Re: Fix Brin Private Spool Initialization (src/backend/access/brin/brin.c)

2023-12-29 Thread Tomas Vondra
On 12/29/23 12:53, Ranier Vilela wrote: > Em qui., 28 de dez. de 2023 às 22:16, Tomas Vondra > mailto:tomas.von...@enterprisedb.com>> > escreveu: > > > > On 12/27/23 12:37, Ranier Vilela wrote: > > Em ter., 26 de dez. de 2023 às 19:07, Tomas Vond

Re: Fix Brin Private Spool Initialization (src/backend/access/brin/brin.c)

2023-12-28 Thread Tomas Vondra
On 12/27/23 12:37, Ranier Vilela wrote: > Em ter., 26 de dez. de 2023 às 19:07, Tomas Vondra > mailto:tomas.von...@enterprisedb.com>> > escreveu: > > > > On 12/26/23 19:10, Ranier Vilela wrote: > > Hi, > >

Re: Statistics Import and Export

2023-12-28 Thread Tomas Vondra
rray type (with ELEMENT=X) but with a custom analyze function, in which case the extra_data may be something entirely different. I suppose the correct solution would be to add an "import" function into the pg_type catalog (next to typanalyze). Or maybe it'd be enough to set it from the typanalyze? After all, that's what sets compute_stats. But maybe it's enough to just do what you did - if we get an MCELEM slot, can it ever contain anything else than array of elements of the attribute array type? I'd bet that'd cause all sorts of issues, no? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: The segmentation fault of Postgresql 9.6.24

2023-12-28 Thread Tomas Vondra
gt; This could be pretty much anything, and without seeing where exactly it fails it's impossible to say. I see you apparently hit the issue repeatedly, and tall the information is *exactly* the same - addresses, code, etc. Try decoding the addresses with addr2line, or even better get a proper backtrace - either from a core file, or using gdb. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Multidimensional Histograms

2023-12-28 Thread Tomas Vondra
On 12/27/23 22:19, Tomas Vondra wrote: > Hello Alexander, > > We actually had histograms in the early patches adding multivariate > statistics [1]. We however ended up removing histograms and only kept > the simpler types, for a couple reasons. > > It might be worth going t

Re: Multidimensional Histograms

2023-12-27 Thread Tomas Vondra
a.edu/~gravano/Papers/2001/sigmod01b.pdf [5] https://cs.gmu.edu/~carlotta/publications/vldb090.pdf [6] https://core.ac.uk/download/pdf/82158702.pdf regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Statistics Import and Export

2023-12-27 Thread Tomas Vondra
I'm not sure about the extension idea. Yes, we could have an extension providing such functions, but do we have any precedent of making pg_upgrade dependent on an external extension? I'd much rather have something built-in that just works, especially if we intend to make it the default behavior (which I think should be our aim here). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Fix Brin Private Spool Initialization (src/backend/access/brin/brin.c)

2023-12-26 Thread Tomas Vondra
TuplesortIndexArg, but BRIN does not need that because we sort the tuples by blkno, and we don't need the descriptors for that. In any case, the _brin_parallel_scan_and_build does not actually need the separate heap/index arguments, those are already in the spool. I'll try to figure out if we want to s

Re: Add the ability to limit the amount of memory that can be allocated to backends.

2023-12-26 Thread Tomas Vondra
e this and return just 1MB block. Sure, this would have to be optional, and not all places can accept a smaller block than requested (when the chunk would not fit into the smaller block). It would require a suitable memory pool API and more work in the memory contexts, but it seems pretty useful. C

Re: Add the ability to limit the amount of memory that can be allocated to backends.

2023-12-26 Thread Tomas Vondra
-c $N -j $N i.e. read-only tests (to not hit I/O), and $N being sufficiently large to maybe also show some concurrency/locking bottlenecks, etc. I may do some benchmarks if I happen to find a bit of time, but maybe you could collect such numbers too? The other benchmark that might be interes

Re: Statistics Import and Export

2023-12-25 Thread Tomas Vondra
version_num from pg_statistic_ext_export where ext_stats_name = 's'), (select stats from pg_statistic_ext_export where ext_stats_name = 's')); WARNING: statistics import has 5 mcv dimensions, but the expects 2. Skipping excess dimensions. ERROR: statist

Re: index prefetching

2023-12-21 Thread Tomas Vondra
d not have even think about that back when index-only scans were added. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: index prefetching

2023-12-21 Thread Tomas Vondra
On 12/21/23 14:27, Andres Freund wrote: > Hi, > > On 2023-12-09 19:08:20 +0100, Tomas Vondra wrote: >> But there's a layering problem that I don't know how to solve - I don't >> see how we could make indexam.c entirely oblivious to the prefetching, >> and move

Re: index prefetching

2023-12-21 Thread Tomas Vondra
On 12/21/23 14:43, Andres Freund wrote: > Hi, > > On 2023-12-21 13:30:42 +0100, Tomas Vondra wrote: >> You're right a lot of this is a guesswork. I don't think we can do much >> better, because it depends on stuff that's out of our control - each OS >> may do thi

Re: logical decoding and replication of sequences, take 2

2023-12-21 Thread Tomas Vondra
, I feel a bit uneasy about it, for similar reasons as Amit. If we start processing records before full snapshot, that seems like moving the assumptions a bit. For example it means we'd create ReorderBufferTXN entries for cases that'd have skipped before. OTOH this is (or should be) only a very temporary period while starting the replication, I believe. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: logical decoding and replication of sequences, take 2

2023-12-21 Thread Tomas Vondra
On 12/19/23 13:54, Christophe Pettus wrote: > Hi, > > I wanted to hop in here on one particular issue: > >> On Dec 12, 2023, at 02:01, Tomas Vondra >> wrote: >> - desirability of the feature: Random IDs (UUIDs etc.) are likely a much >> better solution

Re: index prefetching

2023-12-21 Thread Tomas Vondra
On 12/21/23 07:49, Dilip Kumar wrote: > On Wed, Dec 20, 2023 at 7:11 AM Tomas Vondra > wrote: >> > I was going through to understand the idea, couple of observations > > -- > + for (int i = 0; i < PREFETCH_LRU_SIZE; i++) > + { > + entry = >prefe

Re: index prefetching

2023-12-21 Thread Tomas Vondra
On 12/20/23 20:09, Robert Haas wrote: > On Tue, Dec 19, 2023 at 8:41 PM Tomas Vondra > ... >> I have imagined something like this: >> >> nodeIndexscan / index_getnext_slot() >> -> no callback, all TIDs are prefetched >> >> nodeIndexonlyscan /

Re: index prefetching

2023-12-19 Thread Tomas Vondra
On 12/18/23 22:00, Robert Haas wrote: > On Sat, Dec 9, 2023 at 1:08 PM Tomas Vondra > wrote: >> But there's a layering problem that I don't know how to solve - I don't >> see how we could make indexam.c entirely oblivious to the prefetching, >> and move it entirely to t

Re: Use of additional index columns in rows filtering

2023-12-19 Thread Tomas Vondra
is work in v1. Once the other issues get solved in some way, I may try hacking a WIP, but mostly to try if there's not some design issue that'd make it hard in the future. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Use of additional index columns in rows filtering

2023-12-19 Thread Tomas Vondra
ns. Second, we could disable ScanState->ps.quals if there are index filters, and just do all the work info nodeIndexscan. But that seems quite ugly - in a way, the code already does that, which is where the two loops while (true) { for (;;) { ... } } c

Re: planner chooses incremental but not the best one

2023-12-18 Thread Tomas Vondra
On 12/18/23 11:40, Richard Guo wrote: > > On Mon, Dec 18, 2023 at 7:31 AM Tomas Vondra > mailto:tomas.von...@enterprisedb.com>> > wrote: > > Oh! Now I see what you meant by using the new formula in 84f9a35e3 > depending on how we sum tuples. I agree that

Re: planner chooses incremental but not the best one

2023-12-17 Thread Tomas Vondra
to improve this? > Oh! Now I see what you meant by using the new formula in 84f9a35e3 depending on how we sum tuples. I agree that seems like the right thing. I'm not sure it'll actually help with the issue, though - if I apply the patch, the plan does not actually change (and the cost changes

Re: planner chooses incremental but not the best one

2023-12-17 Thread Tomas Vondra
is confusion. > And this would also allow us to adjust the estimate for the number of > distinct values in estimate_num_groups() for appendrels using the new > formula introduced in 84f9a35e3. I don't follow. Why wouldn't it be using the new formula even without your patch? (using t

Re: brininsert optimization opportunity

2023-12-17 Thread Tomas Vondra
On 12/13/23 09:12, Soumyadeep Chakraborty wrote: > On Tue, Dec 12, 2023 at 3:25 AM Tomas Vondra > wrote: > > >> The attached 0001 patch fixes this by adding the call to validate_index, > which seems like the proper place as it's where the indexInfo is > allocated

Re: How to get started with contribution

2023-12-17 Thread Tomas Vondra
resting. That'll allow you to setup the environment, get familiar with the core and various development tasks (running tests, ..). If you get stuck. ask in this thread and we'll try to help you. [1] https://wiki.postgresql.org/wiki/Developer_FAQ [2] https://commitfest.postgres

Re: brininsert optimization opportunity

2023-12-12 Thread Tomas Vondra
On 12/11/23 16:41, Tomas Vondra wrote: > On 12/11/23 16:00, Alexander Lakhin wrote: >> Hello Tomas and Soumyadeep, >> >> 25.11.2023 23:06, Tomas Vondra wrote: >>> I've done a bit more cleanup on the last version of the patch (renamed >>> the fields

Re: logical decoding and replication of sequences, take 2

2023-12-12 Thread Tomas Vondra
com [2] https://www.postgresql.org/message-id/0bc34f71-7745-dc16-d765-5ba1f0776a3f%40enterprisedb.com -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: brininsert optimization opportunity

2023-12-11 Thread Tomas Vondra
On 12/11/23 16:00, Alexander Lakhin wrote: > Hello Tomas and Soumyadeep, > > 25.11.2023 23:06, Tomas Vondra wrote: >> I've done a bit more cleanup on the last version of the patch (renamed >> the fields to start with bis_ as agreed, rephrased the comments / docs / &g

Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION

2023-12-11 Thread Tomas Vondra
n (to write the check differently for > easier understanding) offlist which I addressed and pushed the patch. > Thanks for taking care of fixing this! regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-08 Thread Tomas Vondra
know if/when I'll get back to this. Thanks for the reviews/reworks/ideas! -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL CompanyFrom cf53c109c73cfa9264df71763e9ec5712f1c1f7f Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Thu, 7 Dec 2023 15:07:04 +0100

Re: logical decoding and replication of sequences, take 2

2023-12-06 Thread Tomas Vondra
On 12/6/23 09:56, Amit Kapila wrote: > On Tue, Dec 5, 2023 at 10:23 PM Tomas Vondra > wrote: >> >> On 12/5/23 13:17, Amit Kapila wrote: >> >>> (b) for transactional >>> cases, we see overhead due to traversing all the top-level txns and >>> check

Re: logical decoding and replication of sequences, take 2

2023-12-06 Thread Tomas Vondra
On 12/6/23 11:19, Amit Kapila wrote: > On Sun, Dec 3, 2023 at 11:56 PM Tomas Vondra > wrote: >> >> On 12/3/23 18:52, Tomas Vondra wrote: >>> ... >>> >> >> Another idea is that maybe we could somehow inform ReorderBuffer whether >> the outp

Re: logical decoding and replication of sequences, take 2

2023-12-06 Thread Tomas Vondra
at'd fix my issue. Also, would this mean we don't need to track the relfilenodes, if we're able to query the catalog? Would we be able to check if the relfilenode was created by the current xact? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: logical decoding and replication of sequences, take 2

2023-12-06 Thread Tomas Vondra
On 12/6/23 10:05, Dilip Kumar wrote: > On Wed, Dec 6, 2023 at 11:12 AM Dilip Kumar wrote: >> >> On Sun, Dec 3, 2023 at 11:22 PM Tomas Vondra >> wrote: >>> > > I was also wondering what happens if the sequence changes are > transactional but

Re: logical decoding and replication of sequences, take 2

2023-12-05 Thread Tomas Vondra
|| ||--66.24%--pg_qsort || | And there's almost no difference between master and build with sequence decoding - see the attached diff-alter-sequence.perf, comparing the two branches (perf diff -c delta-abs). regards -- Tomas Vo

Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION

2023-12-05 Thread Tomas Vondra
t from this much resources, I would be rather surprised if it was faster beyond 8 cores or so. The CPU frequency likely matters much more. Which probably explains why this machine was the slowest. Also, I wonder how much the results vary between the runs. I suppose you only did s single run for eac

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-04 Thread Tomas Vondra
On 12/4/23 16:00, Matthias van de Meent wrote: > On Sun, 3 Dec 2023 at 17:46, Tomas Vondra > wrote: >> On 11/30/23 18:47, Matthias van de Meent wrote: >>> ... >>> >>> I just ran some more tests in less favorable environments, and it &g

Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION

2023-12-04 Thread Tomas Vondra
n't understand what "Performance Machine Linux" is, considering those timings are slower than the other two machines. Also, even if it was a bit slower, does it really matter? I mean, the current code is wrong, can lead to infinite duration if it happens to hit the deadlock. And it's a one-time action, I don't think it's a very sensitive in terms of performance. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Syncrep and improving latency due to WAL throttling

2023-12-03 Thread Tomas Vondra
cond file, which shows latency percentiles for the medium dataset on syncrep. The difference between master (on the left) and the two throttling builds is pretty obvious. It's not exactly the same as "no concurrent bulk loads" in the top row, but not far from it. regards -- Tomas

Re: logical decoding and replication of sequences, take 2

2023-12-03 Thread Tomas Vondra
On 12/3/23 18:52, Tomas Vondra wrote: > ... > > Some time ago I floated the idea of maybe "queuing" the sequence changes > and only replay them on the next commit, somehow. But we did ran into > problems with which snapshot to use, that I didn't know how to solve. &g

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-03 Thread Tomas Vondra
, creates an index (possibly partial), and then does various checks on it (checks number of ranges, queries the table, etc.). It's somewhat primitive but it turned out to be very capable in triggering bugs in BlockNumber arithmetic, emptyTuple allocations, etc. regards -- Tomas Vondra Ente

Re: logical decoding and replication of sequences, take 2

2023-12-01 Thread Tomas Vondra
I've planned to run the case which uses setval() function, > because it > generates more WALs than normal nextval(); > How do you think? > Sure, although I don't think it's much different from the test selecting 40 values from the sequence (in each transaction). That generates about the same amount of WAL. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: logical decoding and replication of sequences, take 2

2023-12-01 Thread Tomas Vondra
On 11/30/23 12:56, Amit Kapila wrote: > On Thu, Nov 30, 2023 at 5:28 AM Tomas Vondra > wrote: >> >> 3) "bad case" - small transactions that generate a lot of relfilenodes >> >> select alter_sequence(); >> >> where the function is defi

Re: [Proposal] global sequence implemented by snowflake ID

2023-12-01 Thread Tomas Vondra
On 12/1/23 07:15, Amit Kapila wrote: > On Thu, Nov 30, 2023 at 5:21 PM Tomas Vondra > wrote: >> >> On 11/30/23 11:56, Amit Kapila wrote: >> >>> >>> This was the key point that I wanted to discuss or hear opinions >>> about. S

Re: [Proposal] global sequence implemented by snowflake ID

2023-11-30 Thread Tomas Vondra
o me what benefits will we get by having replication of > non-global sequences. One thing that comes to mind is replication > covers a subset of use cases (like help in case of failover or > switchover to subscriber) and till the time we have some > implementation of global sequences, it can help users. > What are you going to do about use cases like using logical replication for upgrade to the next major version? Or applications that prefer (or have to) use traditional sequences? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 23:59, Matthias van de Meent wrote: > On Wed, 29 Nov 2023 at 21:56, Tomas Vondra > wrote: >> >> On 11/29/23 21:30, Matthias van de Meent wrote: >>> On Wed, 29 Nov 2023 at 18:55, Tomas Vondra >>> wrote: >>>> I did try to measure how

Re: logical decoding and replication of sequences, take 2

2023-11-29 Thread Tomas Vondra
On 11/29/23 15:41, Tomas Vondra wrote: > ... >> >> One thing that worries me about that approach is that it can suck with >> the workload that has a lot of DDLs that create XLOG_SMGR_CREATE >> records. We have previously fixed some such workloads in logical >> deco

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 21:30, Matthias van de Meent wrote: > On Wed, 29 Nov 2023 at 18:55, Tomas Vondra > wrote: >> >> On 11/29/23 15:52, Tomas Vondra wrote: >>>> ... >>>> >>>> This also made me think a bit more about how we're working with the >

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 15:52, Tomas Vondra wrote: >> ... >> >> This also made me think a bit more about how we're working with the >> tuples. With your latest patch, we always deserialize and re-serialize >> the sorted brin tuples, just in case the next tuple will also be a

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 15:42, Matthias van de Meent wrote: > On Tue, 28 Nov 2023 at 18:59, Tomas Vondra > wrote: >> >> On 11/28/23 16:39, Matthias van de Meent wrote: >>> On Thu, 23 Nov 2023 at 14:35, Tomas Vondra >>> wrote: >>>> On 11/23/23 13:33, Matthias

Re: logical decoding and replication of sequences, take 2

2023-11-29 Thread Tomas Vondra
On 11/29/23 14:42, Amit Kapila wrote: > On Wed, Nov 29, 2023 at 2:59 AM Tomas Vondra > wrote: >> >> I have been hacking on improving the improvements outlined in my >> preceding e-mail, but I have some bad news - I ran into an issue that I >> don't know h

Re: logical decoding and replication of sequences, take 2

2023-11-29 Thread Tomas Vondra
tor, > + MAIN_FORKNUM)); > > How about using the macro: OidIsValid > Same as the other Oid check - consistency. > ~~~ > > 11. ReorderBufferChangeSize > > + if (tup) > + { > + sz += sizeof(HeapTupleData); > + len = tup->tuple.t_len; > + sz += len; > + } > > Why is the 'sz' increment split into 2 parts? > Because the other branches in ReorderBufferChangeSize do it that way. You're right it might be coded on a single line. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-28 Thread Tomas Vondra
On 11/28/23 16:39, Matthias van de Meent wrote: > On Thu, 23 Nov 2023 at 14:35, Tomas Vondra > wrote: >> On 11/23/23 13:33, Matthias van de Meent wrote: >>> The union operator may leak (lots of) memory, so I think it makes >>> sense to keep a context around that can

Re: logical decoding and replication of sequences, take 2

2023-11-28 Thread Tomas Vondra
On 11/28/23 12:32, Amit Kapila wrote: > On Mon, Nov 27, 2023 at 11:45 PM Tomas Vondra > wrote: >> >> I spent a bit of time looking at the proposed change, and unfortunately >> logging just the boolean flag does not work. A good example is this bit >> from a TAP tes

Re: brininsert optimization opportunity

2023-11-27 Thread Tomas Vondra
On 11/27/23 11:34, Tomas Vondra wrote: > > > On 11/27/23 08:37, Richard Guo wrote: >> >> On Mon, Nov 27, 2023 at 1:53 PM Soumyadeep Chakraborty >> mailto:soumyadeep2...@gmail.com>> wrote: >> >> On Sun, Nov 26, 2023 at 9:28 PM Richard Guo

Re: logical decoding and replication of sequences, take 2

2023-11-27 Thread Tomas Vondra
inguish the status, > rd_createSubid and > rd_newRelfilelocatorSubid are used. According to the comment, they would be a > valid value > only when the relation was changed within the transaction > Also, sequences_hash was not needed anymore, so it and related functions were > removed. > > How do you think? > I think it's an a very nice idea, assuming it maintains the current behavior. It makes a lot of code unnecessary, etc. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

<    1   2   3   4   5   6   7   8   9   10   >