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

Issue 29501 optimize sql #30345

Merged
merged 7 commits into from
Oct 15, 2024
Merged

Issue 29501 optimize sql #30345

merged 7 commits into from
Oct 15, 2024

Conversation

erickgonzalez
Copy link
Contributor

@erickgonzalez erickgonzalez commented Oct 15, 2024

This pull request includes various changes to the TemplateFactoryImpl and TemplateSQL classes to improve code consistency and performance. The most significant changes include the addition of a new method to check for index existence, refactoring of SQL query strings, and the introduction of a new startup task for indexing.

New Features:

  • Added a new method checkIndex in DotDatabaseMetaData to verify if an index exists in a table. (dotCMS/src/main/java/com/dotmarketing/common/db/DotDatabaseMetaData.java)

Code Refactoring:

  • Refactored SQL query strings in TemplateFactoryImpl to use constants from TemplateSQL for better maintainability. (dotCMS/src/main/java/com/dotmarketing/portlets/templates/business/TemplateFactoryImpl.java)

Performance Improvements:

  • Introduced a new startup task Task241014AddTemplateValueOnContentletIndex to add an index on the template value of a contentlet, significantly speeding up queries. (dotCMS/src/main/java/com/dotmarketing/startup/runonce/Task241014AddTemplateValueOnContentletIndex.java)
  • Added the new startup task to TaskLocatorUtil. (dotCMS/src/main/java/com/dotmarketing/util/TaskLocatorUtil.java)
  • Updated the PostgreSQL schema to include the new index for contentlet template values. (dotCMS/src/main/resources/postgres.sql)

Bug Fixes:

  • Corrected a typo in a constant name from CONTENTKET_INODE_TABLE_FIELD to CONTENTLET_INODE_TABLE_FIELD in TemplateFactoryImpl. (dotCMS/src/main/java/com/dotmarketing/portlets/templates/business/TemplateFactoryImpl.java)

Test Updates:

  • Updated test suite MainSuite2b to include new and existing tasks. (dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java)
  • Modified TemplateAPITest to remove redundant assertions. (dotcms-integration/src/test/java/com/dotmarketing/portlets/templates/business/TemplateAPITest.java)

This PR fixes: #29501

@erickgonzalez erickgonzalez linked an issue Oct 15, 2024 that may be closed by this pull request
@erickgonzalez erickgonzalez marked this pull request as ready for review October 15, 2024 15:24
Copy link
Contributor

@wezell wezell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work Erick.

@wezell wezell added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 33f27b8 Oct 15, 2024
35 checks passed
@wezell wezell deleted the issue-29501-optimize-sql branch October 15, 2024 17:14
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.

optimize sql query causing slowness on high-traffic sites
3 participants