I believe it has to do with the implementation of my tables, as I get fixed numbers: 1)select * from products => Rows:100 2)select * from products where productid > 5 => Rows:50 3)select * from products where productid = 5 => Rows:25 (and the exact same numbers for the table orders)
How can I define a table that gives back correct metadata for the rows? Right now my tables implement ScannableTable. 2016-09-24 21:15 GMT+03:00 Γιώργος Θεοδωράκης <giwrgosrth...@gmail.com>: > 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 >