feat: Lazy load Lucee SQL views for faster profiler reports#59
Open
sfer79 wants to merge 1 commit intocoldbox-modules:developmentfrom
Open
feat: Lazy load Lucee SQL views for faster profiler reports#59sfer79 wants to merge 1 commit intocoldbox-modules:developmentfrom
sfer79 wants to merge 1 commit intocoldbox-modules:developmentfrom
Conversation
Previously, all three SQL views (Grouped, Timeline, Slowest) were rendered server-side when opening a profiler report, causing significant delays (20+ seconds with many queries) due to prettySql() regex formatting applied to every query across all views. Now SQL views are loaded on-demand via AJAX only when the user clicks on a tab. Loaded views are cached client-side to prevent re-fetching. This reduces initial profiler report load time from ~20s to near-instant. Changes: - Add renderLuceeSqlView handler action for lazy AJAX loading - Refactor luceeSqlPanel.cfm to use Alpine.js fetch on tab click - Extract luceeSqlGrouped.cfm as a standalone partial view - Add loading indicator while SQL view is being fetched
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Lucee SQL panel currently renders all three SQL views (Grouped, Timeline, Slowest) server-side when a profiler report is opened. With many queries (50-200+), the
prettySql()regex formatting applied to every query across all 3 views causes significant delays — 20+ seconds in real-world usage.This PR introduces lazy loading for SQL views:
Result
Profiler report opens near-instantly instead of 20+ seconds. SQL data loads on-demand in ~1-2 seconds per view.
Changes
handlers/Main.cfc— AddedrenderLuceeSqlViewaction that renders a single SQL view (grouped/timeline/slowest) and returns HTMLviews/main/panels/requestTracker/luceeSqlPanel.cfm— Refactored to use Alpine.jsfetch()on tab click instead of server-side rendering all views. Usesdata-profiler-idattribute and.then()/.catch()promise chain for broad browser compatibilityviews/main/panels/requestTracker/luceeSqlGrouped.cfm— Extracted grouped SQL view as a standalone partial (was previously rendered inline)Technical Details
appUrlfrom parent scope (Visualizer/Dock layout) for AJAX endpoint URLdata-profiler-idHTML attribute (avoidsencodeForJavaScriptissues with UUIDs inx-data).then()/.catch()instead ofasync/awaitfor compatibilityloadedViewsobject caches which views have been fetched to prevent redundant requests$refsandinnerHTMLfor each view containerTest Plan