-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`)
- Loading branch information
1 parent
10c59ee
commit 33f27b8
Showing
10 changed files
with
144 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
...in/java/com/dotmarketing/startup/runonce/Task241014AddTemplateValueOnContentletIndex.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import com.dotmarketing.common.db.DotConnect; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.exception.DotRuntimeException; | ||
import com.dotmarketing.startup.StartupTask; | ||
|
||
/** | ||
* This upgrade task adds an index on the template value of a contentlet. This | ||
* GREATLY speeds up queries. | ||
*/ | ||
public class Task241014AddTemplateValueOnContentletIndex implements StartupTask { | ||
|
||
public boolean forceRun() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void executeUpgrade() throws DotDataException, DotRuntimeException { | ||
new DotConnect().setSQL("CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_contentlet_template_value ON contentlet((contentlet_as_json->'fields'->'template'->>'value'))").loadResult(); | ||
|
||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.