Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgmq.purge(queue_name text) performance #298

Open
olirice opened this issue Aug 15, 2024 · 1 comment
Open

pgmq.purge(queue_name text) performance #298

olirice opened this issue Aug 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@olirice
Copy link
Contributor

olirice commented Aug 15, 2024

In pgmq.purge(queue_name text) it uses delete from with no where clause and then collect the row count with GET DIAGNOSTICS

EXECUTE format('DELETE FROM pgmq.%I', qtable);
GET DIAGNOSTICS deleted_count = ROW_COUNT;

If the queue is large that will create a lot of IO and WAL with 1 record per deleted tuple. At scale that could contribute to exhausting IO on the primary and cause replication lag on any replicas

What do you think about swapping it out for something like

SELECT count(*) INTO deleted_count FROM pgmq.my_tab;
TRUNCATE pgmq.my_tab;

since truncate produces a single WAL record a little IO on the primary?

@ChuckHend
Copy link
Contributor

Yea I think this is a good enhancement. We've also seen poor perf when queue grows very large and have used TRUNCATE directly on the queue table as a workaround. I think makes sense to put that in the API.

@ChuckHend ChuckHend added the enhancement New feature or request label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants