use of com.orientechnologies.common.profiler.OProfiler in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelect method revertProfiler.
protected void revertProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams, final OIndexDefinition indexDefinition) {
if (iContext.isRecordingMetrics()) {
iContext.updateMetric("compositeIndexUsed", -1);
}
final OProfiler profiler = Orient.instance().getProfiler();
if (profiler.isRecording()) {
profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", -1);
int params = indexDefinition.getParamCount();
if (params > 1) {
final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed");
profiler.updateCounter(profiler_prefix, "Used composite index in query", -1);
profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", -1);
profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with " + params + " params and " + keyParams.size() + " keys", -1);
}
}
}
use of com.orientechnologies.common.profiler.OProfiler in project orientdb by orientechnologies.
the class PolymorphicQueryTest method testSubclassesIndexesFailed.
@Test
public void testSubclassesIndexesFailed() throws Exception {
database.begin();
OProfiler profiler = Orient.instance().getProfiler();
profiler.startRecording();
for (int i = 0; i < 10000; i++) {
final ODocument doc1 = new ODocument("IndexInSubclassesTestChild1Fail");
doc1.field("name", "name" + i);
doc1.save();
final ODocument doc2 = new ODocument("IndexInSubclassesTestChild2Fail");
doc2.field("name", "name" + i);
doc2.save();
if (i % 100 == 0) {
database.commit();
}
}
database.commit();
long indexUsage = profiler.getCounter("db.demo.query.indexUsed");
long indexUsageReverted = profiler.getCounter("db.demo.query.indexUseAttemptedAndReverted");
if (indexUsage < 0) {
indexUsage = 0;
}
if (indexUsageReverted < 0) {
indexUsageReverted = 0;
}
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from IndexInSubclassesTestBaseFail where name > 'name9995' and name < 'name9999' order by name ASC"));
Assert.assertTrue(result.size() == 6);
long lastIndexUsage = profiler.getCounter("db.demo.query.indexUsed");
long lastIndexUsageReverted = profiler.getCounter("db.demo.query.indexUseAttemptedAndReverted");
if (lastIndexUsage < 0) {
lastIndexUsage = 0;
}
if (lastIndexUsageReverted < 0) {
lastIndexUsageReverted = 0;
}
Assert.assertEquals(lastIndexUsage - indexUsage, lastIndexUsageReverted - indexUsageReverted);
profiler.stopRecording();
}
use of com.orientechnologies.common.profiler.OProfiler in project orientdb by orientechnologies.
the class PolymorphicQueryTest method testBaseWithoutIndexAndSubclassesIndexes.
@Test
public void testBaseWithoutIndexAndSubclassesIndexes() throws Exception {
database.begin();
OProfiler profiler = Orient.instance().getProfiler();
long indexUsage = profiler.getCounter("db.demo.query.indexUsed");
long indexUsageReverted = profiler.getCounter("db.demo.query.indexUseAttemptedAndReverted");
if (indexUsage < 0) {
indexUsage = 0;
}
if (indexUsageReverted < 0) {
indexUsageReverted = 0;
}
profiler.startRecording();
for (int i = 0; i < 10000; i++) {
final ODocument doc0 = new ODocument("IndexInSubclassesTestBase");
doc0.field("name", "name" + i);
doc0.save();
final ODocument doc1 = new ODocument("IndexInSubclassesTestChild1");
doc1.field("name", "name" + i);
doc1.save();
final ODocument doc2 = new ODocument("IndexInSubclassesTestChild2");
doc2.field("name", "name" + i);
doc2.save();
if (i % 100 == 0) {
database.commit();
}
}
database.commit();
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from IndexInSubclassesTestBase where name > 'name9995' and name < 'name9999' order by name ASC"));
Assert.assertTrue(result.size() == 9);
String lastName = result.get(0).field("name");
for (int i = 1; i < result.size(); i++) {
ODocument current = result.get(i);
String currentName = current.field("name");
Assert.assertTrue(lastName.compareTo(currentName) <= 0);
lastName = currentName;
}
Assert.assertEquals(profiler.getCounter("db.demo.query.indexUsed"), indexUsage + 2);
long reverted = profiler.getCounter("db.demo.query.indexUseAttemptedAndReverted");
Assert.assertEquals(reverted < 0 ? 0 : reverted, indexUsageReverted);
result = database.query(new OSQLSynchQuery<ODocument>("select from IndexInSubclassesTestBase where name > 'name9995' and name < 'name9999' order by name DESC"));
Assert.assertTrue(result.size() == 9);
lastName = result.get(0).field("name");
for (int i = 1; i < result.size(); i++) {
ODocument current = result.get(i);
String currentName = current.field("name");
Assert.assertTrue(lastName.compareTo(currentName) >= 0);
lastName = currentName;
}
profiler.stopRecording();
}
Aggregations