Hi, Thanks a lot for the patch! I didn't have a look at it yet, but I (or another of the H2 committers) surely will. We monitor the Google Group, and there is usually no need to create a issue in the bugtracker.
Regards, Thomas On Sat, Jan 25, 2014 at 9:31 AM, Pandu Purnama <[email protected]> wrote: > Hi, thanks for the patch! > I assume this is a bug then? > If so, can we ask H2 dev team to apply this patch to repository? > That way we don't have to manually apply this patch every time we upgrade > H2 version. > > Thanks! > > On Friday, January 24, 2014 8:45:52 PM UTC+7, [email protected] wrote: >> >> replace Methode getCostRangeIndex in org.h2.index.BaseIndex >>> >>> >> protected long getCostRangeIndex(int[] masks, long rowCount, >> TableFilter filter, SortOrder sortOrder) { >> rowCount += Constants.COST_ROW_OFFSET; >> long cost = rowCount; >> long rows = rowCount; >> double totalSelectivity = 0;// totalSelectivity = 100 - ((100 - >> 1) * >> // (100 - 1) / 100) = 1,99 wennn >> // totalSelectivity is an int then >> // totalSelectivity stay = 1 >> if (masks == null) { >> return cost; >> } >> for (int i = 0, len = columns.length; i < len; i++) { >> Column column = columns[i]; >> int index = column.getColumnId(); >> int mask = masks[index]; >> if ((mask & IndexCondition.EQUALITY) == >> IndexCondition.EQUALITY) { >> if (i == columns.length - 1 && getIndexType().isUnique()) >> { >> cost = 3; >> break; >> } >> totalSelectivity = 100 - ((100 - totalSelectivity) * (100 >> - column.getSelectivity()) / 100); >> long distinctRows = (long) (rowCount * totalSelectivity / >> 100); >> if (distinctRows <= 0) { >> distinctRows = 1; >> } >> rows = Math.max(rowCount / distinctRows, 1); >> cost = 2 + rows; >> } else if ((mask & IndexCondition.RANGE) == >> IndexCondition.RANGE) { >> cost = 2 + rows / 4; >> rows = cost;// for compare anothers columns >> } else if ((mask & IndexCondition.START) == >> IndexCondition.START) { >> cost = 2 + rows / 3; >> rows = cost;// for compare anothers columns >> } else if ((mask & IndexCondition.END) == IndexCondition.END) >> { >> cost = rows / 3; >> rows = cost;// for compare anothers columns >> } else { >> break; >> } >> } >> // if the ORDER BY clause matches the ordering of this index, >> // it will be cheaper than another index, so adjust the cost >> accordingly >> if (sortOrder != null) { >> boolean sortOrderMatches = true; >> int coveringCount = 0; >> int[] sortTypes = sortOrder.getSortTypes(); >> for (int i = 0, len = sortTypes.length; i < len; i++) { >> if (i >= indexColumns.length) { >> // we can still use this index if we are sorting by >> more >> // than it's columns, it's just that the coveringCount >> // is lower than with an index that contains >> // more of the order by columns >> break; >> } >> Column col = sortOrder.getColumn(i, filter); >> if (col == null) { >> sortOrderMatches = false; >> break; >> } >> IndexColumn indexCol = indexColumns[i]; >> if (col != indexCol.column) { >> sortOrderMatches = false; >> break; >> } >> int sortType = sortTypes[i]; >> if (sortType != indexCol.sortType) { >> sortOrderMatches = false; >> break; >> } >> coveringCount++; >> } >> if (sortOrderMatches) { >> // "coveringCount" makes sure that when we have two >> // or more covering indexes, we choose the one >> // that covers more >> cost -= coveringCount; >> } >> } >> return cost; >> } >> >> >> >> >> Patch for lucene4.6 and BaseIndex >> >> > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
