Skip to content

Commit

Permalink
fix(mongodb): improve mongodb indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiovaresco committed Aug 3, 2023
1 parent cb4349f commit 159cd7b
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 17 deletions.
Expand Up @@ -19,19 +19,18 @@
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("ApisEnvironmentIdIndexUpgrader")
public class EnvironmentIdIndexUpgrader extends IndexUpgrader {
@Component("ApisEnvironmentIdNameDefinitionVersionIndexUpgrader")
public class EnvironmentIdNameDefinitionVersionIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("apis")
.name("ei1")
.name("ei1n1dv1")
.key("environmentId", ascending())
.key("name", ascending())
.key("definitionVersion", ascending())
.build();
}
}
Expand Up @@ -23,15 +23,16 @@
* @author GraviteeSource Team
*/
@Component("EventsPropertiesDictionaryIdIndexUpgrader")
public class PropertiesDictionaryIdIndexUpgrader extends IndexUpgrader {
public class PropertiesApiIdTypeIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("events")
.name("pdi1")
.key("properties.dictionary_id", ascending())
.name("pa1t1")
.key("properties.api_id", ascending())
.key("type", ascending())
.build();
}
}
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.mongodb.management.upgrade.upgrader.index.eventslatest;
package io.gravitee.repository.mongodb.management.upgrade.upgrader.index.events;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
Expand All @@ -22,16 +22,17 @@
/**
* @author GraviteeSource Team
*/
@Component("EventsLatestPropertyApiIdIndexUpgrader")
public class PropertyApiIdIndexUpgrader extends IndexUpgrader {
@Component("EventsPropertiesApiIdUpdatedAtIndexUpgrader")
public class PropertiesApiIdUpdatedAtIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("events_latest")
.name("pai1")
.collection("events")
.name("pa1u1")
.key("properties.api_id", ascending())
.key("updatedAt", ascending())
.build();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.mongodb.management.upgrade.upgrader.index.events;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("EventsPropertiesDictionaryIdUpdatedAtIndexUpgrader")
public class PropertiesDictionaryIdUpdatedAtIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("events")
.name("pdi1u1")
.key("properties.dictionary_id", ascending())
.key("updatedAt", descending())
.build();
}
}
Expand Up @@ -22,16 +22,17 @@
/**
* @author GraviteeSource Team
*/
@Component("EventsTypeIndexUpgrader")
public class TypeIndexUpgrader extends IndexUpgrader {
@Component("EventsTypeUpdatedAtIndexUpgrader")
public class TypeUpdatedAtIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("events")
.name("t1")
.name("t1u1")
.key("type", ascending())
.key("updatedAt", ascending())
.build();
}
}
@@ -0,0 +1,34 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.mongodb.management.upgrade.upgrader.index.subscriptions;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

@Component("SubscriptionsUpdatedAtAscIndexUpgrader")
public class UpdatedAtAscIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("subscriptions")
.name("ua1")
.key("updatedAt", ascending())
.build();
}
}

0 comments on commit 159cd7b

Please sign in to comment.