db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: Reflection Vs ByteCode Generation
Date Tue, 13 Aug 2013 12:59:59 GMT
On 8/10/13 2:47 AM, Madushanka Fonseka wrote:
> Hi,
>
> I Have been working with Apache derby for last few months as I am into 
> innovating Apache derby to support "Fuzzy Query".
>
> I want to know why apache derby prfers bytecode generation over 
> reflection ?
Hi Madushanka,

A SQL interpreter needs to evaluate lots of expressions. Consider the 
following statement:

   select a+b from t where c*d > e*f;

In this statement, the SQL interpreter has to evaluate

   a+b
   c*d > e*f

For this expression evaluation, all SQL interpreters generate bytecode. 
At least, all SQL interpreters which I know about. For most SQL 
interpreters, the bytecode is something proprietary. At runtime, the 
bytecode is evaluated on a special virtual machine built into the SQL 
interpreter. What is different about Derby is that Derby doesn't define 
its own proprietary bytecode and Derby doesn't supply a special virtual 
machine in its execution layer. Instead, Derby just uses Java bytecode 
and the Java virtual machine for expression evaluation. For a pure-Java 
database like Derby, the traditional approach would mean that every 
expression would be evaluated on 2 virtual machines: first the 
proprietary virtual machine and then ultimately the Java virtual 
machine. The advantages of the Derby approach are supposed to be:

1) Derby doesn't have to maintain its own proprietary virtual machine.

2) Eliminating one of the virtual machines ought to result in measurable 
performance boosts for queries involving expressions and lots of rows.

Reflection is a further issue for expressions which invoke external 
routines coded in Java. When the bytecode generator was created 15 years 
ago, Java reflection was an expensive operation. I believe that the 
performance of reflection has improved significantly since then.

Hope this helps,
-Rick
>
>
> Then I would like out of those two mechanisms what would be the best 
> approach to execute fuzzy queries ?
>
> FYI - Fuzzy Query will look like this.
>
> Select * good students from student,
>
> Select students where avg is rather above 60
>
>
>
> Madushanka Fonseka,
> B.Sc (Eng), M.Sc (reading),
> Snr Software Engineer,
> Virtusa Inc.
>
>


Mime
View raw message