<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: helpdevtools</title>
    <description>The latest articles on DEV Community by helpdevtools (@helpdevtools).</description>
    <link>https://dev.to/helpdevtools</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3835093%2F1aafc485-4203-4299-9a88-e31e7ebbfc22.jpg</url>
      <title>DEV Community: helpdevtools</title>
      <link>https://dev.to/helpdevtools</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/helpdevtools"/>
    <language>en</language>
    <item>
      <title>My dashboard was taking 47 seconds to load. Turns out i was making 600 database queries without knowing it</title>
      <dc:creator>helpdevtools</dc:creator>
      <pubDate>Sat, 21 Mar 2026 14:23:30 +0000</pubDate>
      <link>https://dev.to/helpdevtools/my-dashboard-was-taking-47-seconds-to-load-turns-out-i-was-making-600-database-queries-without-3bkj</link>
      <guid>https://dev.to/helpdevtools/my-dashboard-was-taking-47-seconds-to-load-turns-out-i-was-making-600-database-queries-without-3bkj</guid>
      <description>&lt;p&gt;i was building a simple dashboard. nothing fancy. &lt;br&gt;
just fetch some user data and display it.&lt;/p&gt;

&lt;p&gt;opened it to test something and just stared at &lt;br&gt;
my screen for almost a minute. 47 seconds to load. &lt;br&gt;
for 200 users.&lt;/p&gt;

&lt;p&gt;first i did what every developer does. checked the &lt;br&gt;
network tab. refreshed 3 times. blamed my wifi. &lt;br&gt;
still 47 seconds.&lt;/p&gt;

&lt;p&gt;so i stopped guessing and used an AI prompt to &lt;br&gt;
find the problem.&lt;/p&gt;

&lt;p&gt;here's the prompt i used:&lt;/p&gt;

&lt;p&gt;"Act as a performance engineer. This code is running &lt;br&gt;
slower than expected. The app loads a dashboard that &lt;br&gt;
fetches user data. With 100 users it loads in 200ms. &lt;br&gt;
With 10,000 users it takes 45 seconds and sometimes &lt;br&gt;
crashes. Identify the bottleneck, explain why it's &lt;br&gt;
slow, and rewrite an optimized version with comments &lt;br&gt;
on what changed."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvz1a45hmf4ujxkqor8nj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvz1a45hmf4ujxkqor8nj.png" alt=" " width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the response was not what i expected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p42luc7dr6ews7mgpcv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p42luc7dr6ews7mgpcv.png" alt=" " width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;i was making 3 separate database calls inside a loop. &lt;br&gt;
one for the profile, one for orders, one for last &lt;br&gt;
login. per user. every single time someone opened &lt;br&gt;
the dashboard.&lt;/p&gt;

&lt;p&gt;sounds fine when you write it. its not fine when &lt;br&gt;
you do the math.&lt;/p&gt;

&lt;p&gt;200 users = 600 queries. 10,000 users = 30,000 queries.&lt;/p&gt;

&lt;p&gt;it has a name apparently. the N+1 query problem. one &lt;br&gt;
of the most common performance bugs in backend &lt;br&gt;
development and i had genuinely never heard of it.&lt;/p&gt;

&lt;p&gt;the before and after is kind of embarrassing:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6taspiyepgyvxhosjddl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6taspiyepgyvxhosjddl.png" alt=" " width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;45 seconds to 200ms. the fix replaced the loop with &lt;br&gt;
3 parallel bulk queries using Promise.all. instead of &lt;br&gt;
hitting the database once per user it fetches &lt;br&gt;
everything in one shot for all users at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegtgkmkuz7jf4mcr0elh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegtgkmkuz7jf4mcr0elh.png" alt=" " width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6 changes. maybe 20 minutes to implement.&lt;/p&gt;

&lt;p&gt;the thing that got me is this code looked completely &lt;br&gt;
normal. readable. clean even. no red flags. it just &lt;br&gt;
happened to be silently destroying performance at &lt;br&gt;
any kind of scale.&lt;/p&gt;

&lt;p&gt;i would have never found this by staring at the code. &lt;br&gt;
i had been looking at it for days.&lt;/p&gt;

&lt;p&gt;lesson: working code and fast code are not the same thing.&lt;/p&gt;

&lt;p&gt;going to keep running these prompts on the rest of &lt;br&gt;
the codebase. slightly terrified of what else i'll find.&lt;/p&gt;

&lt;p&gt;if you want to try this on your own code just copy &lt;br&gt;
the prompt above and paste your actual function &lt;br&gt;
instead of mine. i have 99 more prompts like this &lt;br&gt;
organized by category here 👉 &lt;a href="https://payhip.com/b/i7IZa" rel="noopener noreferrer"&gt;https://payhip.com/b/i7IZa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I Was Stuck on a JWT Bug for 2 Hours. This AI Prompt Found the Root Cause in Seconds.</title>
      <dc:creator>helpdevtools</dc:creator>
      <pubDate>Fri, 20 Mar 2026 10:07:54 +0000</pubDate>
      <link>https://dev.to/helpdevtools/i-was-stuck-on-a-jwt-bug-for-2-hours-this-ai-prompt-found-the-root-cause-in-seconds-5ggj</link>
      <guid>https://dev.to/helpdevtools/i-was-stuck-on-a-jwt-bug-for-2-hours-this-ai-prompt-found-the-root-cause-in-seconds-5ggj</guid>
      <description>&lt;p&gt;We've all been there.&lt;/p&gt;

&lt;p&gt;A bug with zero console errors. No obvious &lt;br&gt;
cause. Just broken behavior that makes &lt;br&gt;
absolutely no sense.&lt;/p&gt;

&lt;p&gt;My JWT token was storing correctly after &lt;br&gt;
login — I could see it in localStorage. &lt;br&gt;
But after every single page refresh, the &lt;br&gt;
user was logged out and the token was gone.&lt;/p&gt;

&lt;p&gt;Silent failure. Nothing in the logs. &lt;br&gt;
Hours wasted.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Prompt That Fixed It
&lt;/h2&gt;

&lt;p&gt;Instead of googling for the 100th time, &lt;br&gt;
I used this structured AI prompt:&lt;/p&gt;




&lt;p&gt;"You are a world-class debugger. &lt;br&gt;
I have a bug I cannot solve.&lt;/p&gt;

&lt;p&gt;What the code should do: authenticate a &lt;br&gt;
user with JWT, store the token in &lt;br&gt;
localStorage, and keep them logged in &lt;br&gt;
after page refresh.&lt;/p&gt;

&lt;p&gt;What it actually does: user logs in &lt;br&gt;
successfully, token is stored, but after &lt;br&gt;
page refresh the user is logged out and &lt;br&gt;
the token disappears from localStorage.&lt;/p&gt;

&lt;p&gt;Error: no error in console.&lt;/p&gt;

&lt;p&gt;Code: `// Login function&lt;br&gt;
async function loginUser(email, password) {&lt;br&gt;
  const response = await fetch('/api/auth/login', {&lt;br&gt;
    method: 'POST',&lt;br&gt;
    headers: { 'Content-Type': 'application/json' },&lt;br&gt;
    body: JSON.stringify({ email, password })&lt;br&gt;
  });&lt;br&gt;
  const data = await response.json();&lt;br&gt;
  localStorage.setItem('token', data.token);&lt;br&gt;
  window.location.href = '/dashboard';&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// Check auth on page load&lt;br&gt;
window.onload = function() {&lt;br&gt;
  const token = localStorage.getItem('token');&lt;br&gt;
  if (!token) {&lt;br&gt;
    window.location.href = '/login';&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
`&lt;br&gt;
What I've tried: console.log before &lt;br&gt;
setItem confirms token exists, but after &lt;br&gt;
redirect it's gone.&lt;/p&gt;

&lt;p&gt;Think step by step and solve it."&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happened Next
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpaj5lkw8q42mlvebz2o2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpaj5lkw8q42mlvebz2o2.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Claude immediately identified the root cause:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp53watax14739o6uhhi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp53watax14739o6uhhi.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then gave a complete step by step diagnosis:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkf45w9dl0ohh6qdqj14j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkf45w9dl0ohh6qdqj14j.png" alt=" " width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And a full working fix with comments:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cunakq0lobx3oyc585w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cunakq0lobx3oyc585w.png" alt=" " width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Root Cause
&lt;/h2&gt;

&lt;p&gt;The culprit was a &lt;strong&gt;race condition&lt;/strong&gt; between &lt;br&gt;
&lt;code&gt;localStorage.setItem&lt;/code&gt; and &lt;br&gt;
&lt;code&gt;window.location.href&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The redirect fires before the browser &lt;br&gt;
finishes writing to localStorage. The page &lt;br&gt;
tears down mid-write and the token silently &lt;br&gt;
vanishes. No error. No warning.&lt;/p&gt;

&lt;p&gt;I never would have thought of that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Prompt Works So Well
&lt;/h2&gt;

&lt;p&gt;Most developers ask AI vague questions like &lt;br&gt;
"why is my localStorage not working?" and &lt;br&gt;
get generic answers.&lt;/p&gt;

&lt;p&gt;This prompt works because it forces you to &lt;br&gt;
give the AI everything it needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What the code SHOULD do&lt;/li&gt;
&lt;li&gt;What it ACTUALLY does&lt;/li&gt;
&lt;li&gt;The exact error&lt;/li&gt;
&lt;li&gt;The exact code&lt;/li&gt;
&lt;li&gt;What you already tried&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more context you give, the more &lt;br&gt;
surgical the diagnosis.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want More Prompts Like This?
&lt;/h2&gt;

&lt;p&gt;I built a pack of 100 structured AI prompts &lt;br&gt;
specifically for developers — organized into &lt;br&gt;
8 categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debugging (15 prompts)&lt;/li&gt;
&lt;li&gt;Code Generation (15 prompts)&lt;/li&gt;
&lt;li&gt;Security &amp;amp; Code Review (10 prompts)&lt;/li&gt;
&lt;li&gt;Testing (10 prompts)&lt;/li&gt;
&lt;li&gt;DevOps &amp;amp; Deployment (10 prompts)&lt;/li&gt;
&lt;li&gt;Documentation (10 prompts)&lt;/li&gt;
&lt;li&gt;Career &amp;amp; Interviews (10 prompts)&lt;/li&gt;
&lt;li&gt;Productivity (20 prompts)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each prompt includes:&lt;br&gt;
✔ The exact prompt structure&lt;br&gt;
✔ When to use it&lt;br&gt;
✔ Difficulty level (Beginner/Intermediate/Advanced)&lt;br&gt;
✔ Comes as PDF + searchable Notion template&lt;/p&gt;

&lt;p&gt;👉 Get the full pack here: &lt;a href="https://payhip.com/b/i7IZa" rel="noopener noreferrer"&gt;https://payhip.com/b/i7IZa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Drop any questions in the comments — happy &lt;br&gt;
to share more examples. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
