Skip to content

Conversation

Krishnachaitanyakc
Copy link
Collaborator

  1. Session-Independent Query Detection (QueryNormalizer.ts:40-103)
    • Added isSessionIndependentQuery() method to identify table browsing
      queries
    • Detects simple SELECT * and basic column selection patterns
    • Excludes session-dependent functions (USER(), NOW(), etc.) and complex
      operations
  2. Dual Cache Key Strategy (QueryNormalizer.ts:108-131)
    - Enhanced generateCacheKey() with conditional session logic
    - Session-independent queries: ${connectionId}:${database}
    - Session-dependent queries: ${connectionId}:${database}:${sessionId}
  3. Enhanced Cache Manager (CacheManager.ts)
    - Updated methods to accept optional sessionId parameter
    - Added comprehensive logging for cache strategy monitoring
    - Enhanced metadata tracking with isSessionIndependent field
  4. Database Layer Integration (base.ts:103-146, clickhouse.ts:37-61)
    - Updated BaseDatabaseManager.query() to pass sessionId to cache methods
    - ClickHouse-specific cache optimizations with longer TTL and compression
    - Maintained backward compatibility with existing cache invalidation
  5. Enhanced Logging and Monitoring
    - Detailed cache hit/store logging with strategy information
    - TypeScript error fixes for proper type inference
    - Performance tracking for cache strategy effectiveness

- Added CacheManager to manage caching of query results.
- Introduced QueryCache for storing cached results with eviction policies.
- Implemented QueryNormalizer to standardize SQL queries for consistent caching.
- Updated BaseDatabaseManager to utilize caching in query execution.
- Enhanced ClickHouseManager to handle caching with specific configurations.
- Added IPC handlers for cache management in the main process.
- Created CacheMonitor component for monitoring cache statistics and configuration in the UI.
- Added types for cache entries, metadata, configuration, and statistics.
- Fix boolean type inference issue with regex match results
- Explicitly check for null to ensure proper boolean return type
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review July 27, 2025 18:33
@Krishnachaitanyakc Krishnachaitanyakc self-assigned this Jul 27, 2025
@sahithvibudhi
Copy link
Contributor

This will only save on network round trip and the queries we run to populate the tables in the left pane.

We should probably not do this because, if a user runs a INSERT statement followed by a SELECT. he would not be seeing the latest insertion

@Krishnachaitanyakc thoughts?

@Krishnachaitanyakc
Copy link
Collaborator Author

Good point, let me tweak the implementation to invalidate cache when we perform a write operation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants