---
title: "Discussion on \"Building a Queue System with Supabase and PostgreSQL\" | Hashnode"
description: "Discussion on \"Building a Queue System with Supabase and PostgreSQL\". Supabase is an open-source alternative to Firebase that offers a wide range of capabilities for building robust and scalable applications. One of the key advantages of Supabase is its integration with PostgreSQL, a powerful and reliable database mana..."
url: "https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Building a Queue System with Supabase and PostgreSQL](https://blog.mansueli.com/building-a-queue-system-with-supabase-and-postgresql?utm_source=hashnode&utm_medium=feed)

Supabase is an open-source alternative to Firebase that offers a wide range of capabilities for building robust and scalable applications. One of the key advantages of Supabase is its integration with PostgreSQL, a powerful and reliable database mana...

Jun 20, 2023 · 10 min read · blog.mansueli.com  
Updated Aug 16, 2023  
Read the article

-   [#queue](https://hashnode.com/tag/queue)
-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#supabase](https://hashnode.com/tag/supabase)
-   [#edge-functions](https://hashnode.com/tag/edge-functions)

## Written by

[Rodrigo Mansueli](https://hashnode.com/@mansueli)

@mansueli

  
[View profile](https://hashnode.com/@mansueli)

Supabase Tips

Support Engineer @Supabase | StackOverflow

## Responses 6

Markdown supported · ⌘↵ to post

[Jonathan Hsu](https://hashnode.com/@jhsu)

[Aug 11, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/66b8d59df583f6362a68ce24)

Thank you for this tutorial, it was very helpful to get me started. One thing I'm running into is my edge function running into concurrency limits... Do you have any recommendations for throttling how frequently an edge function can be called?

[Sandy Mildred](https://hashnode.com/@sandymildred221)

[Jun 13, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/666a92f70e155da6d0c0bb0e)

CONSULT A LICENSE PATECH RECOVERY HACKER FOR CRYPTO RECOVERY I would like to express my gratitude to PATECH RECOVERY HACKER for helping me through a difficult period. I was duped into making an online investment in which I was promised a 25% weekly profit, but it turned out to be a scam. I was very angry until I read an article about PATECH Recovery about how they had assisted others in recovering funds. But because Patech Recovery helped me and made things simple for me, I was able to get my cryptocurrency back. If you've been a victim of something similar, get in touch with them Email: patechrecovery @ proton dot me whatsapp---913////730///0531

Show less

[Geoffrey Garrett](https://hashnode.com/@geoffreygarrett)

[May 28, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/665669801c9adcf796fd9ee4)

Really awesome post. The only real solution to queues with PG and Supabase, unless you want to add an additional vendor. The code is great though it's not the most robust. I have race condition issues with it + apparently there's sub-minute cron supported now with pg\_cron 1.50+ though I haven't had success.

Thanks a lot though, I'll try get my code across to you in a minute.

[Ceero4](https://hashnode.com/@Hrine)

[May 16, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/664600080ccfe71a9b5fd0be)

nice post

[Ceero4](https://hashnode.com/@Hrine)

[May 16, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/6645ffd78375ef3ad8678e22)

My hobby is gambling. And finally, I have found a place in India where I can play the best games. I would like to advise you to follow this [odds96.in/en/casino/game/3841-hi-lo](https://odds96.in/en/casino/game/3841-hi-lo) link to the site and learn more about this exciting real money gambling game. If you live in India and have not tried to play it until now, you should definitely pay attention to it, because it will bring you a lot of fun and most importantly, real money.

[Carlito](https://hashnode.com/@Carlito95)

[Dec 6, 2023](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/6570489e37f7fa8c1525eda8)

Hi! Thanks for this awesome tuto. I followed all steps but the status stays as "Processing". When I log the response\_result in the process\_current\_jobs function, I have: response\_result: (SUCCESS,404,"Function not found"). I replaced your supabase functiond urls by mine in the process\_job and retry\_failed\_jobs functions.

Any idea?

Thanks. Best regards, C.

[Bert Cammayo](https://hashnode.com/@ngcammayo)

[Aug 27, 2023](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64eae129cc3035243ea7fb03)

Thank you for sharing your knowledge. Please do not forget to apply RLS on each tables.

[Rodrigo Mansueli](https://hashnode.com/@mansueli)

[Aug 27, 2023](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64eae129cc3035243ea7fb03#reply-64eb90c907b8622e9a9970c5)

Thanks Bert. I can make this more clear moving forward, but you can also follow this previous article to have them set automatically for you:

[blog.mansueli.com/sudo-with-postgres-supabase](https://blog.mansueli.com/sudo-with-postgres-supabase)

[Abhay Pansuriya](https://hashnode.com/@mrPansuriya)

[Jun 12, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64eae129cc3035243ea7fb03#reply-66693758d5a3fb47204fd0bd)

hi there

[Sandy Mildred](https://hashnode.com/@sandymildred221)

[Jun 13, 2024](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64eae129cc3035243ea7fb03#reply-666a9302cef15882ea8b5e2b)

CONSULT A LICENSE PATECH RECOVERY HACKER FOR CRYPTO RECOVERY I would like to express my gratitude to PATECH RECOVERY HACKER for helping me through a difficult period. I was duped into making an online investment in which I was promised a 25% weekly profit, but it turned out to be a scam. I was very angry until I read an article about PATECH Recovery about how they had assisted others in recovering funds. But because Patech Recovery helped me and made things simple for me, I was able to get my cryptocurrency back. If you've been a victim of something similar, get in touch with them Email: patechrecovery @ proton dot me whatsapp---913////730///0531

Show less

[Jeremy Bauman](https://hashnode.com/@jb110)

[Aug 16, 2023](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64dd14f49154427d760d219e)

This section produces "invalid SQL query", I can't seem to figure out why? I have been unable to get this process to work

```
CREATE OR REPLACE FUNCTION schedule_jobs()
RETURNS VOID
AS $$
BEGIN
    -- Schedule retry job
    SELECT cron.schedule(
        'retry_failed_jobs',
        '*/10 * * * *', 
        $$ SELECT retry_failed_jobs(); $$
    );
    -- Schedule first job
    PERFORM cron.schedule(
        'process_current_jobs_if_unlocked_job_1',
        '* * * * *',
        $$ SELECT process_current_jobs_if_unlocked(); $$
    );
    -- Schedule second job with a 20-second delay
    PERFORM pg_sleep(20);
    PERFORM cron.schedule(
        'process_current_jobs_if_unlocked_job_2',
        '* * * * *',
        $$ SELECT process_current_jobs_if_unlocked(); $$
    );
    -- Schedule third job with another 20-second delay
    PERFORM pg_sleep(20);
    PERFORM cron.schedule(
        'process_current_jobs_if_unlocked_job_3',
        '* * * * *',
        $$ SELECT process_current_jobs_if_unlocked(); $$
    );
END;
$$ LANGUAGE plpgsql;
```

[Rodrigo Mansueli](https://hashnode.com/@mansueli)

[Aug 16, 2023](https://hashnode.com/posts/building-a-queue-system-with-supabase-and-postgresql/6491b48a3a9e67f9192111d8/comment/64dd14f49154427d760d219e#reply-64dd23ca4429385b92804dd5)

Sorry, a little oversight from me. If you change the $$ in the function or in each command with a different context it will work:

```
RETURNS VOID
AS $function$
BEGIN
(...)
$function$ LANGUAGE plpgsql;
```

Or on each command:

```
 PERFORM cron.schedule(
        'process_current_jobs_if_unlocked_job_3',
        '* * * * *',
        $command$ SELECT process_current_jobs_if_unlocked(); $command$
    );
```

I'll update the article to fix the example.
