Carrie 🏳️‍⚧️(has the wheel)
banner
veryscarrie.bsky.social
Carrie 🏳️‍⚧️(has the wheel)
@veryscarrie.bsky.social
Egg cracked Oct 23, ‘24. Trapped somewhere between what they see, what I need, what might be and what most likely won’t, the inevitable and the impossible. Looking for me. (She/her (us - plural?)) #teamAnnie #professionalWetBlanket
Just in case you thought you’d slip the most subtle of bangers out there and nobody would see….
October 27, 2025 at 12:58 AM
I blame Dave for his lack of foresight.
August 8, 2025 at 10:33 PM
Hand finally healed from the last button and now there’s another one?
August 8, 2025 at 10:32 PM
Should have done it in Quebec. 18 there.
August 8, 2025 at 10:29 PM
I don’t think they’re calling me back. I’d save them too much money.
August 8, 2025 at 10:28 PM
Ok - had to look that up. I’m an Old. :)

I’d see whether there’s a way to convince it to return the record with the max timestamp that meets your criteria. If you know you only want one and it’s always the newest, it might work better.
August 8, 2025 at 10:01 PM
Could also select the record from that memory table with the max timestamp and avoid the limit altogether.
August 8, 2025 at 9:47 PM
I think if your basic query would be relatively selective in prod (say 5k rows or less), you’re probably faster overall to just select * from (select whatever uses your index order by timestamp desc) limit 1.

Not as pretty but likely uses your index and executes faster.
August 8, 2025 at 9:46 PM
What is the value of the count vs the limit?
August 8, 2025 at 9:00 PM
“Get an explain plan for the query….”

Question will be whether that limit value is too high for whatever is receiving your files.
August 8, 2025 at 8:58 PM
Ok - so you’re pulling data based on a set of indexed values but the query is opting to scan the PK because of the limit.

Maybe start doubling that limit and get an explain plan to n the query. There has to be a point where it’s cheaper to use the index.
August 8, 2025 at 8:57 PM
Other option - if the LIMIT is monkeying with the optimizer (docs suggest it does), what happens with a larger value?

Another thought - if you are exporting only a subset of the table, create a memory table based on your index columns and then export from that?
August 8, 2025 at 8:53 PM