calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Γιώργος Θεοδωράκης <giwrgosrth...@gmail.com>
Subject Using Metadata in Query Optimization
Date Sat, 24 Sep 2016 18:15:18 GMT
Hello,

I am using a HepPlanner for query optimization on logical operators. When I
run the optimizations, I get an optimized plan according to the rules I
have used but wrong metadata results. My code is :

SqlNode sqlNode = planner.parse(query);
SqlNode validatedSqlNode = planner.validate(sqlNode);
final RelNode convertedNode = planner.convert(validatedSqlNode);
final RelMetadataProvider provider =
convertedNode.getCluster().getMetadataProvider();

final List<RelMetadataProvider> list = Lists.newArrayList(provider);
hepPlanner.registerMetadataProviders(list);
final RelMetadataProvider cachingMetaDataProvider = new
CachingRelMetadataProvider(ChainedRelMetadataProvider.of(list), hepPlanner);
convertedNode.accept(new MetaDataProviderModifier(cachingMetaDataProvider));

hepPlanner.setRoot(convertedNode);
RelNode rel = hepPlanner.findBestExp(); // when I print the logical plan it
is correct
rel.accept(new MetaDataProviderModifier(provider));

final RelMetadataQuery mq = RelMetadataQuery.instance();
RelOptCost relCost= mq.getCumulativeCost(rel);
System.out.println("Plan cost is : " + relCost.toString()); //when I print
the cost I get //a fixed number that has nothing to do with the actual size
of my tables


I always get the same numbers from cumulative cost, even if I change the
contents of my tables for the same query. However, the numbers change
before an after optimizing the query, but are still very large.What am I
doing wrong?

Thank you in advance,
 George

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message