Skip to content

[Bug/Performance] App freezes indefinitely when listing Stored Procedures & Functions on MySQL instances with many routines #3835

Closed

Description

@sanortizcanubeapps

What happened?

Environment

  • OS: macOS
  • TablePro Version: Latest
  • Database Engine: MySQL 5.6.51 (legacy)
  • Schema Context: Server hosting multiple databases with a high volume of Stored Procedures and Functions.

Description

When connected to a MySQL database that contains a large number of Stored Procedures and Functions, clicking on or attempting to expand/search the Routines (SPs/Functions) section causes TablePro to hang or freeze indefinitely. The list of routines never loads, and the application becomes unresponsive.

Other clients (such as Navicat or DBeaver) are able to inspect the schema without freezing because they use lightweight metadata queries and lazy loading.

Steps to reproduce

Steps to Reproduce

  1. Establish a connection to a MySQL instance (e.g., MySQL 5.6.x) containing a database with several hundred Stored Procedures and Functions.
  2. Select or enter the specific database.
  3. Attempt to expand the Stored Procedures / Functions list in the sidebar or search routines.
  4. Result: The UI enters a perpetual loading state or freezes completely; routines are never returned.

Expected behavior

Expected Behavior

  • The schema browser should quickly display the routine names and types (e.g., in a virtualized list).
  • Routine bodies/definitions should only be fetched on demand (lazy loaded) when the user clicks to open or edit a specific procedure.
  • The UI thread should remain responsive while metadata queries are being executed in the background.

Actual Behavior

  • The application freezes/locks up completely, likely due to an unindexed, heavy query on information_schema.ROUTINES pulling full routine definitions, or an unhandled client socket timeout while waiting for massive metadata payloads.

Root Cause Analysis & Technical Context

  1. Eager fetching of ROUTINE_DEFINITION:
    Many database clients run SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = '...'. In MySQL 5.6, this forces the engine to compile and serialize the entire routine body for every single procedure into memory/disk temp tables, causing high latency and packet payload bloat.
  2. Missing Lazy Loading:
    Clients that handle this smoothly (like Navicat) separate the discovery phase from the definition fetch:
    • For listing: they only request lightweight headers (e.g., SHOW PROCEDURE STATUS WHERE Db = '...' or SELECT ROUTINE_NAME, ROUTINE_TYPE FROM information_schema.ROUTINES).
    • For editing: they run SHOW CREATE PROCEDURE <name> only when a specific routine is opened.
  3. UI Virtualization:
    Rendering thousands of routine nodes directly in the DOM/tree without virtualization can lock the main process thread.

Suggested Fix

  1. Omit routine body on tree load: Only fetch ROUTINE_NAME, ROUTINE_TYPE, DEFINER, and LAST_ALTERED when populating the sidebar tree.
  2. Fetch DDL on demand: Execute SHOW CREATE PROCEDURE / FUNCTION <name> only upon user interaction.
  3. Fallback/alternative for legacy MySQL: For MySQL 5.1–5.6, consider querying SHOW PROCEDURE STATUS WHERE Db = DATABASE() or reading lightweight columns from mysql.proc to avoid information_schema locks.

Database type

MySQL / MariaDB

TablePro version

0.82.2

Platform

macOS

OS version & hardware

macOS Golgen Gate 27.0.1

Installed from (Linux)

None

Debugging information (Linux)


Screenshots / Logs

Image

Activity

  1. added
    bug
    on Oct 25, 2026
  2. self-assigned this
    on Oct 26, 2026
  3. J2TeamNNL commented on Oct 26, 2026

    @J2TeamNNL
    Contributor

    Reproduced slow routine discovery on MySQL 5.6.51 and opened #3839.

    The listing already avoids ROUTINE_DEFINITION and fetches DDL with SHOW CREATE on demand. The measured bottleneck is the correlated information_schema.PARAMETERS subquery: it repeats parameter-catalog work for each routine.

    With three databases and 503 routines in the selected database, three runs measured:

    Approach Time
    Existing query 9.55–10.38 s
    Two schema-scoped queries, merged in Swift 0.215–0.249 s

    The actual Swift merge returned the same metadata for every row, including no-argument routines and same-name procedures/functions. Byte grouping also keeps parameter signatures separate for case-distinct schema names. A native smoke test of the rebuilt plugin fetched 503 routines in 84 ms; its server log shows two catalog reads and SHOW CREATE only on explicit request. This reproduces the slow database query, not an indefinite UI freeze. Timings include Docker CLI overhead.

    The PR keeps the catalogs separate rather than using a derived-table join, following the driver's existing foreign-key compatibility path for ShardingSphere-Proxy. It preserves the legacy path without a PARAMETERS catalog and leaves DDL loading on demand. Two queries add a round trip; a small 9-routine dataset was slower (0.147–0.174 s versus 0.080–0.100 s).

    The PR includes regression tests, the reason in code comments, and a self-cleaning probe:
    python3 apple/scripts/probes/check-mysql-routine-listing.py --base c8512d092

    Local MySQLDriver build, lint and 136 isolated MySQLCore tests pass. Full verification limits and CI status are recorded in the PR.

  4. self-assigned this
    on Oct 26, 2026
  5. added theissue type on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions