Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored and Optimized Query Cache with PgSQL Support #4703

Open
wants to merge 23 commits into
base: v3.0
Choose a base branch
from

Conversation

rahim-kanji
Copy link
Collaborator

@rahim-kanji rahim-kanji commented Oct 9, 2024

Introduced separate query processors for MySQL and PostgreSQL.

  • Added Query Cache Support for PgSQL:

    • Introduced new variables for PgSQL Query Cache management:

      • pgsql-query_cache_size_MB
      • pgsql-query_cache_soft_ttl_pct
      • pgsql-query_cache_stores_empty_result
      • pgsql-query_cache_handle_warnings (not yet utilized)
    • Overwriting Transaction Status:

      • Sending current transaction state to the client when a result is fetched from the query cache. At the moment, this doesn’t distinguish between normal and error transaction states—both are treated same.
    • Updated behavior:

      • Prioritizes pgsql_thread___query_cache_size_MB over pgsql_thread___threshold_resultset_size when determining if query results should be cached. (same is now true for MySQL)
  • Cache Lifetime Management:

    • Replaced manual reference counting with std::shared_ptr to simplify cache entry lifecycle management. This improves memory handling and reduces complexity.
  • Unified Purging Logic:

    • Refactored the query cache purging logic to use a single thread for both MySQL and PgSQL cache entries.
  • Code Cleanup:

    • Removed unnecessary methods and data members to make the code more maintainable and less cluttered.
  • Performance Optimization:

    • Optimized memory management, reducing memory footprint and improving performance.
  • TAP Tests:

    • pgsql-query_cache_soft_ttl_pct-t.cpp: This test verifies that query cache entries are refreshed upon reaching 'pgsql-query_cache_soft_ttl_pct' value.
    • pgsql-query_cache_test-t.cpp: This test verifies complete functionality of query cache module.
    • mysql-reg_test_4723_query_cache_stores_empty_result-t.cpp: regression test

Closes #4689
Closes #4723

* Added Query Cache Support for PgSQL:

	* Introduced new variables for PgSQL Query Cache management:
		* pgsql-query_cache_size_MB
		* pgsql-query_cache_soft_ttl_pct
		* pgsql-query_cache_stores_empty_result
		* pgsql-query_cache_handle_warnings (not yet utilized)
	* Overwriting Transaction Status:
		* Sending current transaction state to the client when a result is
 returned from the query cache.
		* This currently does not differentiate between normal and error
transaction states—both are treated as active transaction states.

* Cache Lifetime Management:
	Replaced manual reference counting with std::shared_ptr to efficiently manage the lifecycle of cache entries,
ensuring proper memory deallocation and reducing complexity.

* Unified Purging Logic:
	Refactored the query cache purging logic to use a single thread for both
MySQL and PgSQL cache entries.

* Code Cleanup:
	Removed unnecessary methods and data members to streamline the codebase
and improve maintainability.

* Performance Optimization:
	Improved memory management, reducing memory footprint and enhancing
performance.
@mirostauder
Copy link
Collaborator

Can one of the admins verify this patch?

@rahim-kanji rahim-kanji marked this pull request as ready for review October 9, 2024 10:58
This test verifies that query cache entries are refreshed upon reaching 'pgsql-query_cache_soft_ttl_pct' value.
@rahim-kanji rahim-kanji linked an issue Oct 15, 2024 that may be closed by this pull request
…ery_rules, pgsql-query_cache_stores_empty_result and mysql-query_cache_stores_empty_result value should be considered when determining whether to store empty result sets
…ize_MB setting takes precedence over mysql_thread___threshold_resultset_size
@rahim-kanji rahim-kanji changed the title Refactored and Optimized Query Cache with PgSQL Support [WIP] Refactored and Optimized Query Cache with PgSQL Support Oct 25, 2024
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.

Add Query Cache support for PostgreSQL
2 participants