Why your Supabase or Firebase bill spiked: polling loops and how to find them

Updated November 17, 2026

Database bills rarely spike because of real users. They spike because one screen makes a thousand requests where it should make one. These are the usual causes.

Polling that never stops

useEffect(() => {
  setInterval(loadMessages, 1000); // no cleanup
}, []);

Without return () => clearInterval(id), every navigation back to the page adds another interval. Ten visits later, one tab makes ten requests a second. If you need live data, prefer a realtime subscription, and always clean up.

Realtime listeners that re-subscribe

useEffect(() => {
  const channel = supabase.channel("room").on(/* ... */).subscribe();
}, [filters]); // no unsubscribe, and filters changes often

Each change of filters opens another channel. Remove the channel in the cleanup function.

Queries inside loops (N+1)

for (const post of posts) {
  post.author = await supabase.from("profiles").select().eq("id", post.author_id).single();
}

Fifty posts, fifty-one queries. Fetch the related rows in one query with a join or an in filter.

Fetching everything

select("*") on a table that grows, with no limit, gets slower and more expensive every week. Paginate, and select only the columns the screen uses.

Find them

These are hard to spot by reading, because each piece looks fine on its own. Periderm flags intervals and listeners without cleanup, database calls inside loops and short polling intervals, with the file and line:

npm i -g periderm-cli
periderm scan

Run it as you build, so the loop is caught the day it's written, not the day the invoice arrives.

more guides