You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@empire-db.apache.org by Ivan Nemeth <iv...@gmail.com> on 2014/09/24 16:14:07 UTC

DBReader performance suggestion

Hi,

the DBReader can be much faster for resultsets with many columns if the
getFieldIndex(ColumnExpr c) method uses some kind of caching. The following
code is 10 times faster for a resultset with 20000 rows and 70 columns.

public class MyDBReader extends DBReader {

private static final long serialVersionUID = 1L;
 private Map<ColumnExpr, Integer> fieldIndices = new HashMap<ColumnExpr,
Integer>();

@Override
public int getFieldIndex(ColumnExpr column) {
Integer i = fieldIndices.get(column);
if (i == null){
i = super.getFieldIndex(column);
fieldIndices.put(column, i);
}
return i;
}

}

What do you think?

Regards,
Ivan

Re: DBReader performance suggestion

Posted by Francis De Brabandere <fr...@gmail.com>.
Rainer, what do you think about this one?

Cheers,
F

On 29 September 2014 08:16, ivan nemeth <iv...@forumdigital.net> wrote:
> Hi Francis,
>
> ok, here it is:
>
> https://issues.apache.org/jira/browse/EMPIREDB-213
>
> Regards,
> Ivan
>
>
> On Sun, Sep 28, 2014 at 8:57 PM, Francis De Brabandere <fr...@gmail.com>
> wrote:
>>
>> Hi Ivan,
>>
>> Would you mind creating at ticket for this issue?
>> https://issues.apache.org/jira/browse/EMPIREDB
>>
>> Thanks,
>> Francis
>>
>> On 24 September 2014 16:14, Ivan Nemeth <iv...@gmail.com> wrote:
>> > Hi,
>> >
>> > the DBReader can be much faster for resultsets with many columns if the
>> > getFieldIndex(ColumnExpr c) method uses some kind of caching. The
>> > following
>> > code is 10 times faster for a resultset with 20000 rows and 70 columns.
>> >
>> > public class MyDBReader extends DBReader {
>> >
>> > private static final long serialVersionUID = 1L;
>> > private Map<ColumnExpr, Integer> fieldIndices = new HashMap<ColumnExpr,
>> > Integer>();
>> >
>> > @Override
>> > public int getFieldIndex(ColumnExpr column) {
>> > Integer i = fieldIndices.get(column);
>> > if (i == null){
>> > i = super.getFieldIndex(column);
>> > fieldIndices.put(column, i);
>> > }
>> > return i;
>> > }
>> >
>> > }
>> >
>> > What do you think?
>> >
>> > Regards,
>> > Ivan
>
>

Re: DBReader performance suggestion

Posted by ivan nemeth <iv...@forumdigital.net>.
Hi Francis,

ok, here it is:

https://issues.apache.org/jira/browse/EMPIREDB-213

Regards,
Ivan


On Sun, Sep 28, 2014 at 8:57 PM, Francis De Brabandere <fr...@gmail.com>
wrote:

> Hi Ivan,
>
> Would you mind creating at ticket for this issue?
> https://issues.apache.org/jira/browse/EMPIREDB
>
> Thanks,
> Francis
>
> On 24 September 2014 16:14, Ivan Nemeth <iv...@gmail.com> wrote:
> > Hi,
> >
> > the DBReader can be much faster for resultsets with many columns if the
> > getFieldIndex(ColumnExpr c) method uses some kind of caching. The
> following
> > code is 10 times faster for a resultset with 20000 rows and 70 columns.
> >
> > public class MyDBReader extends DBReader {
> >
> > private static final long serialVersionUID = 1L;
> > private Map<ColumnExpr, Integer> fieldIndices = new HashMap<ColumnExpr,
> > Integer>();
> >
> > @Override
> > public int getFieldIndex(ColumnExpr column) {
> > Integer i = fieldIndices.get(column);
> > if (i == null){
> > i = super.getFieldIndex(column);
> > fieldIndices.put(column, i);
> > }
> > return i;
> > }
> >
> > }
> >
> > What do you think?
> >
> > Regards,
> > Ivan
>

Re: DBReader performance suggestion

Posted by Francis De Brabandere <fr...@gmail.com>.
Hi Ivan,

Would you mind creating at ticket for this issue?
https://issues.apache.org/jira/browse/EMPIREDB

Thanks,
Francis

On 24 September 2014 16:14, Ivan Nemeth <iv...@gmail.com> wrote:
> Hi,
>
> the DBReader can be much faster for resultsets with many columns if the
> getFieldIndex(ColumnExpr c) method uses some kind of caching. The following
> code is 10 times faster for a resultset with 20000 rows and 70 columns.
>
> public class MyDBReader extends DBReader {
>
> private static final long serialVersionUID = 1L;
> private Map<ColumnExpr, Integer> fieldIndices = new HashMap<ColumnExpr,
> Integer>();
>
> @Override
> public int getFieldIndex(ColumnExpr column) {
> Integer i = fieldIndices.get(column);
> if (i == null){
> i = super.getFieldIndex(column);
> fieldIndices.put(column, i);
> }
> return i;
> }
>
> }
>
> What do you think?
>
> Regards,
> Ivan