Skip to content

Commit

Permalink
Programming exercise: Speed up version control access log queries wit…
Browse files Browse the repository at this point in the history
…h a database index
  • Loading branch information
krusche committed Nov 12, 2024
1 parent 65bc890 commit 749b301
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface VcsAccessLogRepository extends ArtemisJpaRepository<VcsAccessLo
WHERE vcsAccessLog.participation.id = :participationId
ORDER BY vcsAccessLog.timestamp DESC
LIMIT 1
""")
""")
Optional<VcsAccessLog> findNewestByParticipationId(@Param("participationId") long participationId);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet id="20241112123600" author="krusche">
<preConditions onFail="MARK_RAN">
<!-- Check if the index does not exist before adding it -->
<not>
<indexExists indexName="vcs_access_log_participation_id" tableName="vcs_access_log"/>
</not>
</preConditions>

<createIndex indexName="vcs_access_log_participation_id" tableName="vcs_access_log" unique="false">
<column name="participation_id"/>
</createIndex>
</changeSet>
</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/resources/config/liquibase/master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<include file="classpath:config/liquibase/changelog/20241010101010_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20241018053210_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20241023456789_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20241112123600_changelog.xml" relativeToChangelogFile="false"/>

<!-- NOTE: please use the format "YYYYMMDDhhmmss_changelog.xml", i.e. year month day hour minutes seconds and not something else! -->
<!-- we should also stay in a chronological order! -->
Expand Down

0 comments on commit 749b301

Please sign in to comment.