Skip to content
animorio
IT
Back to the library

Query plan

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.3 KBGSAP 28 KBFreeDownload the zip

The execution plan of a slow SQL query, on a light ground: three steps as a tree, Limit, Sort and Seq Scan, each with its bar and its milliseconds, and at the top the total time in red, 842 ms. Turning the index on, the full table read becomes an Index Scan, the sort is no longer needed and its row folds away, the bars empty and the total drops to 0.4 ms, in green. Pointing at a step tells you how much of the total it takes.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Query plan" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Query plan</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the plan of a slow SQL query as a small tree with the time of each step; adding the index turns the full
         scan into an index scan, the sort step is no longer needed and folds away, and the total drops -->
    <section class="qp" data-qp aria-label="Query plan">
      <p class="qp__sql"><b>select</b> * <b>from</b> orders <b>where</b> status = 'open' <b>order by</b> created_at <b>limit</b> 20</p>

      <div class="qp__top">
        <span class="qp__label">Execution time</span>
        <p class="qp__total"><b data-outtotal>842</b><i>ms</i></p>
      </div>

      <ul class="qp__tree" data-tree>
        <li class="qp__node" data-node="limit" tabindex="0">
          <div class="qp__in">
            <span class="qp__name">Limit</span><span class="qp__ms" data-ms>0.1 ms</span>
            <span class="qp__rows">returns 20 rows</span>
            <span class="qp__bar"><i data-fill></i></span>
          </div>
        </li>
        <li class="qp__node" data-node="sort" tabindex="0">
          <div class="qp__in">
            <svg class="qp__elbow" viewBox="0 0 14 24" aria-hidden="true"><path pathLength="1" d="M1 0v10a6 6 0 0 0 6 6h6"></path></svg>
            <span class="qp__name">Sort</span><span class="qp__ms" data-ms>118 ms</span>
            <span class="qp__rows">orders 48,300 rows by created_at</span>
            <span class="qp__bar"><i data-fill></i></span>
          </div>
        </li>
        <li class="qp__node" data-node="scan" tabindex="0">
          <div class="qp__in">
            <svg class="qp__elbow" viewBox="0 0 14 24" aria-hidden="true"><path pathLength="1" d="M1 0v10a6 6 0 0 0 6 6h6"></path></svg>
            <span class="qp__name"><span class="qp__clip"><span data-outscan>Seq Scan on orders</span></span></span><span class="qp__ms" data-ms>724 ms</span>
            <span class="qp__rows"><span class="qp__clip"><span data-outrows>reads 1,204,118 rows, keeps 48,300</span></span></span>
            <span class="qp__bar"><i data-fill></i></span>
          </div>
        </li>
      </ul>

      <button type="button" class="qp__switch" role="switch" aria-checked="false" data-switch>
        <span class="qp__track" aria-hidden="true"><i></i></span>
        <span class="qp__what">Index on <code>(status, created_at)</code></span>
      </button>
      <p class="qp__hint"><span class="qp__clip"><span data-outhint>The scan takes 86% of the time</span></span></p>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

35 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Query plan” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On warm white, with no card: at the top a line of SQL in a monospaced face, “select * from orders where status = 'open' order by created_at limit 20”, and a thin rule under it. Then “Execution time” on the left and on the right the large red number “842” with “ms”. Below, three steps like a staircase, tied by small drawn elbows: “Limit”, 0.1 ms, “returns 20 rows”; “Sort”, 118 ms, “orders 48,300 rows by created_at”; “Seq Scan on orders”, 724 ms in red, “reads 1,204,118 rows, keeps 48,300”. Each step has a thin bar as long as its time: the scan’s is red and almost full. At the bottom a switch, off, “Index on (status, created_at)”, and the line “The scan takes 86% of the time”. Turning the switch on, the knob snaps across and goes green, “Seq Scan” rolls into “Index Scan on orders”, “reads 20 rows, already in order”, the Sort row folds away and is gone, the scan moves up a level with its elbow drawn again, the bars empty and the total counts down to “0.4”, green; the line says “No sort needed, 2,105 times faster”. Turning it off brings everything back. Hovering a step fades the others and the line says how much that step takes.

How it works

Two plans

Two objects with the times of the three steps, the slow one and the fast one: the switch picks which one is read, and bars, numbers and texts come from it.

The same scale

The fast plan’s bars are measured on the slow plan’s total: that is why they stay almost empty, and that is where the gain shows.

The folding row

With the index the rows come out already in order: the Sort step loses its height and goes, and the scan moves in by one level.

The counting total

The large number does not jump: a value goes down from 842 to 0.4 and is rewritten every frame, whole above ten and with one decimal below.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#1f9d6bThe colour of the fast query, with the index.
HOTscript.js#d8402fThe colour of the most expensive step.
SCAN_MSscript.js724How many milliseconds the full table read costs.
SORT_MSscript.js118How many milliseconds the sort costs.
INDEXscript.jsfalseOn, it opens with the index already active.
LOOPscript.jstrueLeft alone, the demo’s pointer points at the slow step, turns the index on and off.

Try them in the Playground

When to use it

On the page of a managed database, an ORM or a performance tool, to show what an index changes; the same tree with bars carries the steps of a build, the calls of a slow request, the legs of a shipment or the lines of a quote before and after a discount.

On phones

The block is at most 332 pixels wide and about 330 tall. The SQL line wraps on two lines; the switch is 44 pixels tall and the steps also open by touch and keyboard.

With reduced motion

No rolling, counting or folding: turning the index on, texts, bars, total and tree are in place at once. The demo’s pointer does not start.

Pitfalls

  • The folding row’s height is moved by GSAP: no CSS transition on the same property, or the two fight.
  • The hidden step leaves the keyboard and screen readers too, not only the view.
  • The most expensive step is not told by red alone: the bottom line writes it, with the percentage.
  • A bar at zero cannot be seen: a sliver always stays, so you can tell the step is there.
  • Times, rows and table are invented, but the plan is plausible: an index on (status, created_at) gives the rows already in order and really removes the Sort step.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.3 KB; the libraries: GSAP 28 KB.

Testing

Tested on 1 December 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations