Accessing database through bsh script.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing database through bsh script.

vijay Si
Is there any funtionality provided for using aggregate functions
(sum,min,max..) and count()  for querrying to data base through bsh.

for egg: how can we write following in BSH :

Select sum(order_id),sum(grand_total) from order_header  where
order_type_id="PURCHASE_ORDER";

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
Use the GenericDelegator and related classes, I think. Or maybe not. I can't recall the aggregate
functions there.

The entity definitions do have those, though. The <view-entity>? Oh yes, the <view-entity>.

Try using DynamicViewEntity to construct a <view-entity>.

Jonathon

vijay Si wrote:

> Is there any funtionality provided for using aggregate functions
> (sum,min,max..) and count()  for querrying to data base through bsh.
>
> for egg: how can we write following in BSH :
>
> Select sum(order_id),sum(grand_total) from order_header  where
> order_type_id="PURCHASE_ORDER";
>
> Regards
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date: 9/14/2007 8:59 AM

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

vijay Si
Hi Jonathon,

i cannot use the view-entity for querrying, as it would cause a performance
hit. Is there any other method to get the above querry. Do u know of any
ways to do it through bsh script.


Regards


On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:

>
> Use the GenericDelegator and related classes, I think. Or maybe not. I
> can't recall the aggregate
> functions there.
>
> The entity definitions do have those, though. The <view-entity>? Oh yes,
> the <view-entity>.
>
> Try using DynamicViewEntity to construct a <view-entity>.
>
> Jonathon
>
> vijay Si wrote:
> > Is there any funtionality provided for using aggregate functions
> > (sum,min,max..) and count()  for querrying to data base through bsh.
> >
> > for egg: how can we write following in BSH :
> >
> > Select sum(order_id),sum(grand_total) from order_header  where
> > order_type_id="PURCHASE_ORDER";
> >
> > Regards
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> 9/14/2007 8:59 AM
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
There's no other (easy) way to query database, aside from using the Entity Engine (which was what
I suggested).

If you're worried about performance hit with a huge (and unconditional) cross-product, see
http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
https://issues.apache.org/jira/browse/OFBIZ-1232

Jonathon

vijay Si wrote:

> Hi Jonathon,
>
> i cannot use the view-entity for querrying, as it would cause a performance
> hit. Is there any other method to get the above querry. Do u know of any
> ways to do it through bsh script.
>
>
> Regards
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>> can't recall the aggregate
>> functions there.
>>
>> The entity definitions do have those, though. The <view-entity>? Oh yes,
>> the <view-entity>.
>>
>> Try using DynamicViewEntity to construct a <view-entity>.
>>
>> Jonathon
>>
>> vijay Si wrote:
>>> Is there any funtionality provided for using aggregate functions
>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>
>>> for egg: how can we write following in BSH :
>>>
>>> Select sum(order_id),sum(grand_total) from order_header  where
>>> order_type_id="PURCHASE_ORDER";
>>>
>>> Regards
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>> 9/14/2007 8:59 AM
>>
>>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date: 9/14/2007 8:59 AM

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

vijay Si
Jonathon

It seems that other option left is to use a jdbc connection to database. Is
it also imperative then, that for very complex querries having
"groupby"..."having" and other clauses it is better to use jdbc method of
connection.

How does it affect the ofbiz philosophy of architecture if i use jdbc for
executing these querries. As right now i cannot find any ways of
implementing those aggregate functions(sum,min,max...) through Entity Engine
(without creating views). Also do you have any idea of performance behaviour
on using jdbc connection?

Thanks.


On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:

>
> There's no other (easy) way to query database, aside from using the Entity
> Engine (which was what
> I suggested).
>
> If you're worried about performance hit with a huge (and unconditional)
> cross-product, see
> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
> https://issues.apache.org/jira/browse/OFBIZ-1232
>
> Jonathon
>
> vijay Si wrote:
> > Hi Jonathon,
> >
> > i cannot use the view-entity for querrying, as it would cause a
> performance
> > hit. Is there any other method to get the above querry. Do u know of any
> > ways to do it through bsh script.
> >
> >
> > Regards
> >
> >
> > On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> >> Use the GenericDelegator and related classes, I think. Or maybe not. I
> >> can't recall the aggregate
> >> functions there.
> >>
> >> The entity definitions do have those, though. The <view-entity>? Oh
> yes,
> >> the <view-entity>.
> >>
> >> Try using DynamicViewEntity to construct a <view-entity>.
> >>
> >> Jonathon
> >>
> >> vijay Si wrote:
> >>> Is there any funtionality provided for using aggregate functions
> >>> (sum,min,max..) and count()  for querrying to data base through bsh.
> >>>
> >>> for egg: how can we write following in BSH :
> >>>
> >>> Select sum(order_id),sum(grand_total) from order_header  where
> >>> order_type_id="PURCHASE_ORDER";
> >>>
> >>> Regards
> >>>
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------
> >>>
> >>> No virus found in this incoming message.
> >>> Checked by AVG Free Edition.
> >>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> >> 9/14/2007 8:59 AM
> >>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> 9/14/2007 8:59 AM
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

BJ Freeman
look at
framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh

vijay Si sent the following on 9/15/2007 10:27 AM:

> Jonathon
>
> It seems that other option left is to use a jdbc connection to database. Is
> it also imperative then, that for very complex querries having
> "groupby"..."having" and other clauses it is better to use jdbc method of
> connection.
>
> How does it affect the ofbiz philosophy of architecture if i use jdbc for
> executing these querries. As right now i cannot find any ways of
> implementing those aggregate functions(sum,min,max...) through Entity Engine
> (without creating views). Also do you have any idea of performance behaviour
> on using jdbc connection?
>
> Thanks.
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>> There's no other (easy) way to query database, aside from using the Entity
>> Engine (which was what
>> I suggested).
>>
>> If you're worried about performance hit with a huge (and unconditional)
>> cross-product, see
>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>
>> Jonathon
>>
>> vijay Si wrote:
>>> Hi Jonathon,
>>>
>>> i cannot use the view-entity for querrying, as it would cause a
>> performance
>>> hit. Is there any other method to get the above querry. Do u know of any
>>> ways to do it through bsh script.
>>>
>>>
>>> Regards
>>>
>>>
>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>> can't recall the aggregate
>>>> functions there.
>>>>
>>>> The entity definitions do have those, though. The <view-entity>? Oh
>> yes,
>>>> the <view-entity>.
>>>>
>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>
>>>> Jonathon
>>>>
>>>> vijay Si wrote:
>>>>> Is there any funtionality provided for using aggregate functions
>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>
>>>>> for egg: how can we write following in BSH :
>>>>>
>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>> order_type_id="PURCHASE_ORDER";
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>>
>>>>>
>> ------------------------------------------------------------------------
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>> 9/14/2007 8:59 AM
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>> 9/14/2007 8:59 AM
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

RE: Accessing database through bsh script.

SkipDever
In reply to this post by vijay Si
vijay

The performance hit I think would be higher in a bash script.  I think there
is no question about that.

But, if you insist

List purchaseOrders = delegator.findByAnd("OrderHeader",
UtilMisc.toMap("orderTypeId","PURCHASE_ORDER"));
if(!UtilValidate.isEmpty(purchaseOrders))
{
        ...
        while(interator.hasNext())
        {
                ...
                double amount = 0;
                Double dAmount = order.getDouble("grandTotal");
                if(dAmount != null)
                {
                        amount = dAmount.doubleValue();
                }
                mytotal += amount;
                mycount++;
        }
}

Each of these class calls uses reflection.
Better to write this in java if it will be used lots.

Better still to use the view entity that Jonathon suggested.

Skip


-----Original Message-----
From: vijay Si [mailto:[hidden email]]
Sent: Saturday, September 15, 2007 9:11 AM
To: [hidden email]
Subject: Re: Accessing database through bsh script.


Hi Jonathon,

i cannot use the view-entity for querrying, as it would cause a performance
hit. Is there any other method to get the above querry. Do u know of any
ways to do it through bsh script.


Regards


On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:

>
> Use the GenericDelegator and related classes, I think. Or maybe not. I
> can't recall the aggregate
> functions there.
>
> The entity definitions do have those, though. The <view-entity>? Oh yes,
> the <view-entity>.
>
> Try using DynamicViewEntity to construct a <view-entity>.
>
> Jonathon
>
>  Si wrote:
> > Is there any funtionality provided for using aggregate functions
> > (sum,min,max..) and count()  for querrying to data base through bsh.
> >
> > for egg: how can we write following in BSH :
> >
> > Select sum(order_id),sum(grand_total) from order_header  where
> > order_type_id="PURCHASE_ORDER";
> >
> > Regards
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> 9/14/2007 8:59 AM
>
>

Reply | Threaded
Open this post in threaded view
|

RE: Accessing database through bsh script.

SkipDever
In reply to this post by vijay Si
In my testing, there is an approximate 20msec hit using the entity engine
over raw jdbc, depending of course on the query, is there a seca involved,
etc.

Skip

-----Original Message-----
From: vijay Si [mailto:[hidden email]]
Sent: Saturday, September 15, 2007 10:28 AM
To: [hidden email]
Subject: Re: Accessing database through bsh script.


Jonathon

It seems that other option left is to use a jdbc connection to database. Is
it also imperative then, that for very complex querries having
"groupby"..."having" and other clauses it is better to use jdbc method of
connection.

How does it affect the ofbiz philosophy of architecture if i use jdbc for
executing these querries. As right now i cannot find any ways of
implementing those aggregate functions(sum,min,max...) through Entity Engine
(without creating views). Also do you have any idea of performance behaviour
on using jdbc connection?

Thanks.


On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:

>
> There's no other (easy) way to query database, aside from using the Entity
> Engine (which was what
> I suggested).
>
> If you're worried about performance hit with a huge (and unconditional)
> cross-product, see
> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
> https://issues.apache.org/jira/browse/OFBIZ-1232
>
> Jonathon
>
> vijay Si wrote:
> > Hi Jonathon,
> >
> > i cannot use the view-entity for querrying, as it would cause a
> performance
> > hit. Is there any other method to get the above querry. Do u know of any
> > ways to do it through bsh script.
> >
> >
> > Regards
> >
> >
> > On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> >> Use the GenericDelegator and related classes, I think. Or maybe not. I
> >> can't recall the aggregate
> >> functions there.
> >>
> >> The entity definitions do have those, though. The <view-entity>? Oh
> yes,
> >> the <view-entity>.
> >>
> >> Try using DynamicViewEntity to construct a <view-entity>.
> >>
> >> Jonathon
> >>
> >> vijay Si wrote:
> >>> Is there any funtionality provided for using aggregate functions
> >>> (sum,min,max..) and count()  for querrying to data base through bsh.
> >>>
> >>> for egg: how can we write following in BSH :
> >>>
> >>> Select sum(order_id),sum(grand_total) from order_header  where
> >>> order_type_id="PURCHASE_ORDER";
> >>>
> >>> Regards
> >>>
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------
> >>>
> >>> No virus found in this incoming message.
> >>> Checked by AVG Free Edition.
> >>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> >> 9/14/2007 8:59 AM
> >>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> 9/14/2007 8:59 AM
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

vijay Si
No there is no seca involved, also i wanted to know that ones i use view
entities then can i access the retrieved results from the database in the
bsh script, as i need to have those reusults in bsh script.



On 9/16/07, skip@theDevers <[hidden email]> wrote:

>
> In my testing, there is an approximate 20msec hit using the entity engine
> over raw jdbc, depending of course on the query, is there a seca involved,
> etc.
>
> Skip
>
> -----Original Message-----
> From: vijay Si [mailto:[hidden email]]
> Sent: Saturday, September 15, 2007 10:28 AM
> To: [hidden email]
> Subject: Re: Accessing database through bsh script.
>
>
> Jonathon
>
> It seems that other option left is to use a jdbc connection to database.
> Is
> it also imperative then, that for very complex querries having
> "groupby"..."having" and other clauses it is better to use jdbc method of
> connection.
>
> How does it affect the ofbiz philosophy of architecture if i use jdbc for
> executing these querries. As right now i cannot find any ways of
> implementing those aggregate functions(sum,min,max...) through Entity
> Engine
> (without creating views). Also do you have any idea of performance
> behaviour
> on using jdbc connection?
>
> Thanks.
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> >
> > There's no other (easy) way to query database, aside from using the
> Entity
> > Engine (which was what
> > I suggested).
> >
> > If you're worried about performance hit with a huge (and unconditional)
> > cross-product, see
> > http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
> > https://issues.apache.org/jira/browse/OFBIZ-1232
> >
> > Jonathon
> >
> > vijay Si wrote:
> > > Hi Jonathon,
> > >
> > > i cannot use the view-entity for querrying, as it would cause a
> > performance
> > > hit. Is there any other method to get the above querry. Do u know of
> any
> > > ways to do it through bsh script.
> > >
> > >
> > > Regards
> > >
> > >
> > > On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> > >> Use the GenericDelegator and related classes, I think. Or maybe not.
> I
> > >> can't recall the aggregate
> > >> functions there.
> > >>
> > >> The entity definitions do have those, though. The <view-entity>? Oh
> > yes,
> > >> the <view-entity>.
> > >>
> > >> Try using DynamicViewEntity to construct a <view-entity>.
> > >>
> > >> Jonathon
> > >>
> > >> vijay Si wrote:
> > >>> Is there any funtionality provided for using aggregate functions
> > >>> (sum,min,max..) and count()  for querrying to data base through bsh.
> > >>>
> > >>> for egg: how can we write following in BSH :
> > >>>
> > >>> Select sum(order_id),sum(grand_total) from order_header  where
> > >>> order_type_id="PURCHASE_ORDER";
> > >>>
> > >>> Regards
> > >>>
> > >>>
> > >>>
> > >>>
> > ------------------------------------------------------------------------
> > >>>
> > >>> No virus found in this incoming message.
> > >>> Checked by AVG Free Edition.
> > >>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> > >> 9/14/2007 8:59 AM
> > >>
> > >>
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > > No virus found in this incoming message.
> > > Checked by AVG Free Edition.
> > > Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> > 9/14/2007 8:59 AM
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

Jacques Le Roux
Administrator
In reply to this post by vijay Si
http://ofbiz.apache.org/docs/entity.html look at Grouping and Summary Data

Jacques

De : "vijay Si" <[hidden email]>

> Is there any funtionality provided for using aggregate functions
> (sum,min,max..) and count()  for querrying to data base through bsh.
>
> for egg: how can we write following in BSH :
>
> Select sum(order_id),sum(grand_total) from order_header  where
> order_type_id="PURCHASE_ORDER";
>
> Regards
>
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
In reply to this post by SkipDever
20msec of what total? That is, what percentage is that 20msec?

I'm assuming there is grouping and summary data in the query?

Another important question is, how many tables, conditionals, etc?

BUT... before you waste time answering my questions, the real question is this. Exactly what kind
of query is Vijay trying to optimize? Always best to treat the exact problem encountered.

Jonathon

skip@theDevers wrote:

> In my testing, there is an approximate 20msec hit using the entity engine
> over raw jdbc, depending of course on the query, is there a seca involved,
> etc.
>
> Skip
>
> -----Original Message-----
> From: vijay Si [mailto:[hidden email]]
> Sent: Saturday, September 15, 2007 10:28 AM
> To: [hidden email]
> Subject: Re: Accessing database through bsh script.
>
>
> Jonathon
>
> It seems that other option left is to use a jdbc connection to database. Is
> it also imperative then, that for very complex querries having
> "groupby"..."having" and other clauses it is better to use jdbc method of
> connection.
>
> How does it affect the ofbiz philosophy of architecture if i use jdbc for
> executing these querries. As right now i cannot find any ways of
> implementing those aggregate functions(sum,min,max...) through Entity Engine
> (without creating views). Also do you have any idea of performance behaviour
> on using jdbc connection?
>
> Thanks.
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>> There's no other (easy) way to query database, aside from using the Entity
>> Engine (which was what
>> I suggested).
>>
>> If you're worried about performance hit with a huge (and unconditional)
>> cross-product, see
>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>
>> Jonathon
>>
>> vijay Si wrote:
>>> Hi Jonathon,
>>>
>>> i cannot use the view-entity for querrying, as it would cause a
>> performance
>>> hit. Is there any other method to get the above querry. Do u know of any
>>> ways to do it through bsh script.
>>>
>>>
>>> Regards
>>>
>>>
>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>> can't recall the aggregate
>>>> functions there.
>>>>
>>>> The entity definitions do have those, though. The <view-entity>? Oh
>> yes,
>>>> the <view-entity>.
>>>>
>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>
>>>> Jonathon
>>>>
>>>> vijay Si wrote:
>>>>> Is there any funtionality provided for using aggregate functions
>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>
>>>>> for egg: how can we write following in BSH :
>>>>>
>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>> order_type_id="PURCHASE_ORDER";
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>>
>>>>>
>> ------------------------------------------------------------------------
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>> 9/14/2007 8:59 AM
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>> 9/14/2007 8:59 AM
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
In reply to this post by vijay Si
Vijay,

 > It seems that other option left is to use a jdbc connection to database.

BJ Freeman's suggestion with org.ofbiz.entity.jdbc.SQLProcessor will serve you here. It's as close
to using raw JDBC as you can get. Any more raw than that, and you may be cursing and swearing
about how manual and menial the task is.

 > Is it also imperative then, that for very complex querries having
 > "groupby"..."having" and other clauses it is better to use jdbc method of
 > connection.

I would say this. If the queries are complex, all the more you should use the Entity Engine
(DynamicViewEntity or just <view-entity>).

Execution speed is important, true. However, so is bug-free development! Using raw JDBC,
maintaining your queries will be a nightmare (such as changes, maintenance, debugging, etc). That
is if you can even get past CREATING your queries CORRECTLY in the first place!

When I used raw JDBC for complex queries spanning over multiple tables, I had to strictly
structure my queries into "clean JOIN hierarchies". Lots of work.

Before long, raw JDBC gave way to some APIs (much like the Entity Engine, but much weaker), even
in PHP where things can be easily done in "raw and ugly" way. The "raw and ugly" way just wasn't
cutting it. Look at the new Zend framework (for PHP), and you'll see the evolution towards
something like OFBiz's Entity Engine.

 > How does it affect the ofbiz philosophy of architecture if i use jdbc for
 > executing these querries.

Not good. Centralizing all DB access through the Entity Engine will make your codes easier to
maintain. Any optimizations to the Entity Engine will benefit all of your DB queries all at once.

 > As right now i cannot find any ways of implementing those aggregate
 > functions(sum,min,max...) through Entity Engine (without creating views).

On the topic of views. Let's take PHP as an example, the biggest facilitator of the "just hack it"
philosophy.

Like I said above, complex queries spanning multiple tables are easiest to maintain if you
structure them cleanly into views first. Then those views can be reused over and over in many
places, with minimal chance for errors. You'll see PHP coders either putting the views into the
RDBMS itself (for VERY FAST execution speeds), or at least defining the views even in PHP codes.

In OFBiz's case, the Entity Engine doesn't seem to make use of RDBMS view mechanisms, IIRC. Yes,
that'll mean a performance hit in execution speeds.

However, the common practice is to just get the software up and running first, coded CLEANLY for
easy management and changes in future. Optimize later. Of course, optimize in areas where there
performance is hit worst, for biggest ROI.

 > Also do you have any idea of performance behaviour on using jdbc connection?

Not sure. But my guess is that raw JDBC could be as much as 100 times faster than using
DynamicViewEntity. But the question you should ask is... does that matter? Are you making so many
instances of the same query that will warrant optimizing it 100 fold?

Jonathon

vijay Si wrote:

> Jonathon
>
> It seems that other option left is to use a jdbc connection to database. Is
> it also imperative then, that for very complex querries having
> "groupby"..."having" and other clauses it is better to use jdbc method of
> connection.
>
> How does it affect the ofbiz philosophy of architecture if i use jdbc for
> executing these querries. As right now i cannot find any ways of
> implementing those aggregate functions(sum,min,max...) through Entity Engine
> (without creating views). Also do you have any idea of performance behaviour
> on using jdbc connection?
>
> Thanks.
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>> There's no other (easy) way to query database, aside from using the Entity
>> Engine (which was what
>> I suggested).
>>
>> If you're worried about performance hit with a huge (and unconditional)
>> cross-product, see
>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>
>> Jonathon
>>
>> vijay Si wrote:
>>> Hi Jonathon,
>>>
>>> i cannot use the view-entity for querrying, as it would cause a
>> performance
>>> hit. Is there any other method to get the above querry. Do u know of any
>>> ways to do it through bsh script.
>>>
>>>
>>> Regards
>>>
>>>
>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>> can't recall the aggregate
>>>> functions there.
>>>>
>>>> The entity definitions do have those, though. The <view-entity>? Oh
>> yes,
>>>> the <view-entity>.
>>>>
>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>
>>>> Jonathon
>>>>
>>>> vijay Si wrote:
>>>>> Is there any funtionality provided for using aggregate functions
>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>
>>>>> for egg: how can we write following in BSH :
>>>>>
>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>> order_type_id="PURCHASE_ORDER";
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>>
>>>>>
>> ------------------------------------------------------------------------
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>> 9/14/2007 8:59 AM
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>> 9/14/2007 8:59 AM
>>
>>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.21/1010 - Release Date: 9/15/2007 7:54 PM

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
In reply to this post by vijay Si
Vijay,

No problem. In BSH scripts, you can use the DynamicViewEntity or even the <view-entity>. Bear in
mind that BSH scripts (in OFBiz's case) is actually Java. Whatever is possible in Java (almost
whatever) is also possible in BSH scripts. In BSH scripts, you can even do some "classes" and
method encapsulation and code organization, much like what you can do in Java. (I haven't fully
tested classes and scope, though).

The DynamicaViewEntity, GenericDelegator, GenericValue, etc, those can be used to access the
database. Even your need for grouping and summary data is served.

Just about everything JDBC can do, the EntityEngine can do, I'd say. All the way down to DISTINCT
values, ResultSet type (scroll_sensitive, scroll_insensitive, etc) even.

Jonathon

vijay Si wrote:

> No there is no seca involved, also i wanted to know that ones i use view
> entities then can i access the retrieved results from the database in the
> bsh script, as i need to have those reusults in bsh script.
>
>
>
> On 9/16/07, skip@theDevers <[hidden email]> wrote:
>> In my testing, there is an approximate 20msec hit using the entity engine
>> over raw jdbc, depending of course on the query, is there a seca involved,
>> etc.
>>
>> Skip
>>
>> -----Original Message-----
>> From: vijay Si [mailto:[hidden email]]
>> Sent: Saturday, September 15, 2007 10:28 AM
>> To: [hidden email]
>> Subject: Re: Accessing database through bsh script.
>>
>>
>> Jonathon
>>
>> It seems that other option left is to use a jdbc connection to database.
>> Is
>> it also imperative then, that for very complex querries having
>> "groupby"..."having" and other clauses it is better to use jdbc method of
>> connection.
>>
>> How does it affect the ofbiz philosophy of architecture if i use jdbc for
>> executing these querries. As right now i cannot find any ways of
>> implementing those aggregate functions(sum,min,max...) through Entity
>> Engine
>> (without creating views). Also do you have any idea of performance
>> behaviour
>> on using jdbc connection?
>>
>> Thanks.
>>
>>
>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>> There's no other (easy) way to query database, aside from using the
>> Entity
>>> Engine (which was what
>>> I suggested).
>>>
>>> If you're worried about performance hit with a huge (and unconditional)
>>> cross-product, see
>>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>>
>>> Jonathon
>>>
>>> vijay Si wrote:
>>>> Hi Jonathon,
>>>>
>>>> i cannot use the view-entity for querrying, as it would cause a
>>> performance
>>>> hit. Is there any other method to get the above querry. Do u know of
>> any
>>>> ways to do it through bsh script.
>>>>
>>>>
>>>> Regards
>>>>
>>>>
>>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>>> Use the GenericDelegator and related classes, I think. Or maybe not.
>> I
>>>>> can't recall the aggregate
>>>>> functions there.
>>>>>
>>>>> The entity definitions do have those, though. The <view-entity>? Oh
>>> yes,
>>>>> the <view-entity>.
>>>>>
>>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>>
>>>>> Jonathon
>>>>>
>>>>> vijay Si wrote:
>>>>>> Is there any funtionality provided for using aggregate functions
>>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>>
>>>>>> for egg: how can we write following in BSH :
>>>>>>
>>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>>> order_type_id="PURCHASE_ORDER";
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>> ------------------------------------------------------------------------
>>>>>> No virus found in this incoming message.
>>>>>> Checked by AVG Free Edition.
>>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>>> 9/14/2007 8:59 AM
>>>>>
>>>>>
>>>>
>>>>
>> ------------------------------------------------------------------------
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>> 9/14/2007 8:59 AM
>>>
>>>
>>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.21/1010 - Release Date: 9/15/2007 7:54 PM

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

vijay Si
Thanks for replies.......

On 9/16/07, Jonathon -- Improov <[hidden email]> wrote:

>
> Vijay,
>
> No problem. In BSH scripts, you can use the DynamicViewEntity or even the
> <view-entity>. Bear in
> mind that BSH scripts (in OFBiz's case) is actually Java. Whatever is
> possible in Java (almost
> whatever) is also possible in BSH scripts. In BSH scripts, you can even do
> some "classes" and
> method encapsulation and code organization, much like what you can do in
> Java. (I haven't fully
> tested classes and scope, though).
>
> The DynamicaViewEntity, GenericDelegator, GenericValue, etc, those can be
> used to access the
> database. Even your need for grouping and summary data is served.
>
> Just about everything JDBC can do, the EntityEngine can do, I'd say. All
> the way down to DISTINCT
> values, ResultSet type (scroll_sensitive, scroll_insensitive, etc) even.
>
> Jonathon
>
> vijay Si wrote:
> > No there is no seca involved, also i wanted to know that ones i use view
> > entities then can i access the retrieved results from the database in
> the
> > bsh script, as i need to have those reusults in bsh script.
> >
> >
> >
> > On 9/16/07, skip@theDevers <[hidden email]> wrote:
> >> In my testing, there is an approximate 20msec hit using the entity
> engine
> >> over raw jdbc, depending of course on the query, is there a seca
> involved,
> >> etc.
> >>
> >> Skip
> >>
> >> -----Original Message-----
> >> From: vijay Si [mailto:[hidden email]]
> >> Sent: Saturday, September 15, 2007 10:28 AM
> >> To: [hidden email]
> >> Subject: Re: Accessing database through bsh script.
> >>
> >>
> >> Jonathon
> >>
> >> It seems that other option left is to use a jdbc connection to
> database.
> >> Is
> >> it also imperative then, that for very complex querries having
> >> "groupby"..."having" and other clauses it is better to use jdbc method
> of
> >> connection.
> >>
> >> How does it affect the ofbiz philosophy of architecture if i use jdbc
> for
> >> executing these querries. As right now i cannot find any ways of
> >> implementing those aggregate functions(sum,min,max...) through Entity
> >> Engine
> >> (without creating views). Also do you have any idea of performance
> >> behaviour
> >> on using jdbc connection?
> >>
> >> Thanks.
> >>
> >>
> >> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> >>> There's no other (easy) way to query database, aside from using the
> >> Entity
> >>> Engine (which was what
> >>> I suggested).
> >>>
> >>> If you're worried about performance hit with a huge (and
> unconditional)
> >>> cross-product, see
> >>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
> >>> https://issues.apache.org/jira/browse/OFBIZ-1232
> >>>
> >>> Jonathon
> >>>
> >>> vijay Si wrote:
> >>>> Hi Jonathon,
> >>>>
> >>>> i cannot use the view-entity for querrying, as it would cause a
> >>> performance
> >>>> hit. Is there any other method to get the above querry. Do u know of
> >> any
> >>>> ways to do it through bsh script.
> >>>>
> >>>>
> >>>> Regards
> >>>>
> >>>>
> >>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
> >>>>> Use the GenericDelegator and related classes, I think. Or maybe not.
> >> I
> >>>>> can't recall the aggregate
> >>>>> functions there.
> >>>>>
> >>>>> The entity definitions do have those, though. The <view-entity>? Oh
> >>> yes,
> >>>>> the <view-entity>.
> >>>>>
> >>>>> Try using DynamicViewEntity to construct a <view-entity>.
> >>>>>
> >>>>> Jonathon
> >>>>>
> >>>>> vijay Si wrote:
> >>>>>> Is there any funtionality provided for using aggregate functions
> >>>>>> (sum,min,max..) and count()  for querrying to data base through
> bsh.
> >>>>>>
> >>>>>> for egg: how can we write following in BSH :
> >>>>>>
> >>>>>> Select sum(order_id),sum(grand_total) from order_header  where
> >>>>>> order_type_id="PURCHASE_ORDER";
> >>>>>>
> >>>>>> Regards
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>
> ------------------------------------------------------------------------
> >>>>>> No virus found in this incoming message.
> >>>>>> Checked by AVG Free Edition.
> >>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> >>>>> 9/14/2007 8:59 AM
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>
> ------------------------------------------------------------------------
> >>>> No virus found in this incoming message.
> >>>> Checked by AVG Free Edition.
> >>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
> >>> 9/14/2007 8:59 AM
> >>>
> >>>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.487 / Virus Database: 269.13.21/1010 - Release Date:
> 9/15/2007 7:54 PM
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Accessing database through bsh script.

SkipDever
In reply to this post by jonwimp
I did some simple tests to retrieve data back when I was doings comparisons
of SOAP and XML-RPC performance. This test was on the Product table with
2000 sequential keys and then doing a binary halving to retrieve the
records, i.e. record 1000 first, followed by 500 and then 1500, etc (to
overcome database caching).

I did this in a loop both for
delegator.findByAnd("Product",UtilMisc.toMap("partyId", client));

and

r = sStatement.executeQuery("SELECT * FROM " + DATABASENAME + " where " +
FID + " = '" + client + "'");

These ran in separate loops, one after the other and I moved the order so
the delegrator group ran first and then second.

The results were that it took an averate of 6 msecs to do the executeQuery
call and 23 msecs to do the delegator call.

Skip

-----Original Message-----
From: Jonathon -- Improov [mailto:[hidden email]]
Sent: Sunday, September 16, 2007 3:44 AM
To: [hidden email]
Subject: Re: Accessing database through bsh script.


20msec of what total? That is, what percentage is that 20msec?

I'm assuming there is grouping and summary data in the query?

Another important question is, how many tables, conditionals, etc?

BUT... before you waste time answering my questions, the real question is
this. Exactly what kind
of query is Vijay trying to optimize? Always best to treat the exact problem
encountered.

Jonathon

skip@theDevers wrote:

> In my testing, there is an approximate 20msec hit using the entity engine
> over raw jdbc, depending of course on the query, is there a seca involved,
> etc.
>
> Skip
>
> -----Original Message-----
> From: vijay Si [mailto:[hidden email]]
> Sent: Saturday, September 15, 2007 10:28 AM
> To: [hidden email]
> Subject: Re: Accessing database through bsh script.
>
>
> Jonathon
>
> It seems that other option left is to use a jdbc connection to database.
Is
> it also imperative then, that for very complex querries having
> "groupby"..."having" and other clauses it is better to use jdbc method of
> connection.
>
> How does it affect the ofbiz philosophy of architecture if i use jdbc for
> executing these querries. As right now i cannot find any ways of
> implementing those aggregate functions(sum,min,max...) through Entity
Engine
> (without creating views). Also do you have any idea of performance
behaviour
> on using jdbc connection?
>
> Thanks.
>
>
> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>> There's no other (easy) way to query database, aside from using the
Entity

>> Engine (which was what
>> I suggested).
>>
>> If you're worried about performance hit with a huge (and unconditional)
>> cross-product, see
>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>
>> Jonathon
>>
>> vijay Si wrote:
>>> Hi Jonathon,
>>>
>>> i cannot use the view-entity for querrying, as it would cause a
>> performance
>>> hit. Is there any other method to get the above querry. Do u know of any
>>> ways to do it through bsh script.
>>>
>>>
>>> Regards
>>>
>>>
>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>> can't recall the aggregate
>>>> functions there.
>>>>
>>>> The entity definitions do have those, though. The <view-entity>? Oh
>> yes,
>>>> the <view-entity>.
>>>>
>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>
>>>> Jonathon
>>>>
>>>> vijay Si wrote:
>>>>> Is there any funtionality provided for using aggregate functions
>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>
>>>>> for egg: how can we write following in BSH :
>>>>>
>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>> order_type_id="PURCHASE_ORDER";
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>>
>>>>>
>> ------------------------------------------------------------------------
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>> 9/14/2007 8:59 AM
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>> 9/14/2007 8:59 AM
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
I did not resist to resurrect this old thread :
http://www.nabble.com/Dev---RFC%3A-ofbiz-entity-sql%2890--done%29-tf1313496.html#a3500828

FWIW

Jacques

De : "Jacques Le Roux" <[hidden email]>

> http://ofbiz.apache.org/docs/entity.html look at Grouping and Summary Data
>
> Jacques
>
> De : "vijay Si" <[hidden email]>
> > Is there any funtionality provided for using aggregate functions
> > (sum,min,max..) and count()  for querrying to data base through bsh.
> >
> > for egg: how can we write following in BSH :
> >
> > Select sum(order_id),sum(grand_total) from order_header  where
> > order_type_id="PURCHASE_ORDER";
> >
> > Regards
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

jonwimp
JLR,

You mean... to write a parser that parses raw "OFBiz SQL" (with OFBiz data types), and translates
that into RDBMS-specific SQL?

Jonathon

Jacques Le Roux wrote:

> I did not resist to resurrect this old thread :
> http://www.nabble.com/Dev---RFC%3A-ofbiz-entity-sql%2890--done%29-tf1313496.html#a3500828
>
> FWIW
>
> Jacques
>
> De : "Jacques Le Roux" <[hidden email]>
>> http://ofbiz.apache.org/docs/entity.html look at Grouping and Summary Data
>>
>> Jacques
>>
>> De : "vijay Si" <[hidden email]>
>>> Is there any funtionality provided for using aggregate functions
>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>
>>> for egg: how can we write following in BSH :
>>>
>>> Select sum(order_id),sum(grand_total) from order_header  where
>>> order_type_id="PURCHASE_ORDER";
>>>
>>> Regards
>>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

Jacques Le Roux
Administrator
It was more to see reaction and mostly to let know people not aware of this post. Also because I saw some exchanges on the ML about
the possible Adam's return in the "OFBiz team".

Jacques

De : "Jonathon -- Improov" <[hidden email]>

> JLR,
>
> You mean... to write a parser that parses raw "OFBiz SQL" (with OFBiz data types), and translates
> that into RDBMS-specific SQL?
>
> Jonathon
>
> Jacques Le Roux wrote:
> > I did not resist to resurrect this old thread :
> > http://www.nabble.com/Dev---RFC%3A-ofbiz-entity-sql%2890--done%29-tf1313496.html#a3500828
> >
> > FWIW
> >
> > Jacques
> >
> > De : "Jacques Le Roux" <[hidden email]>
> >> http://ofbiz.apache.org/docs/entity.html look at Grouping and Summary Data
> >>
> >> Jacques
> >>
> >> De : "vijay Si" <[hidden email]>
> >>> Is there any funtionality provided for using aggregate functions
> >>> (sum,min,max..) and count()  for querrying to data base through bsh.
> >>>
> >>> for egg: how can we write following in BSH :
> >>>
> >>> Select sum(order_id),sum(grand_total) from order_header  where
> >>> order_type_id="PURCHASE_ORDER";
> >>>
> >>> Regards
> >>>
> >
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: Accessing database through bsh script.

David E Jones
In reply to this post by SkipDever

Are you sure about these results? The test case sounds really funny, but however it was done if the same operations are being done with both this sort of difference would REALLY surprise me. In the first 2-3 years of development on entity engine I spent around 200 hours doing profiling and optimization, and based on that the comparison to JDBC was that the entity engine generally had around a 10-20% overhead over JDBC, and generally much less (because compared to the network overhead the EE wrapper objects, especially using recycled objects, has very little overhead).

It has been about 3 years since that, but I'd still be really surprised if something has changed that significantly since then.

-David


skip@theDevers wrote:

> I did some simple tests to retrieve data back when I was doings comparisons
> of SOAP and XML-RPC performance. This test was on the Product table with
> 2000 sequential keys and then doing a binary halving to retrieve the
> records, i.e. record 1000 first, followed by 500 and then 1500, etc (to
> overcome database caching).
>
> I did this in a loop both for
> delegator.findByAnd("Product",UtilMisc.toMap("partyId", client));
>
> and
>
> r = sStatement.executeQuery("SELECT * FROM " + DATABASENAME + " where " +
> FID + " = '" + client + "'");
>
> These ran in separate loops, one after the other and I moved the order so
> the delegrator group ran first and then second.
>
> The results were that it took an averate of 6 msecs to do the executeQuery
> call and 23 msecs to do the delegator call.
>
> Skip
>
> -----Original Message-----
> From: Jonathon -- Improov [mailto:[hidden email]]
> Sent: Sunday, September 16, 2007 3:44 AM
> To: [hidden email]
> Subject: Re: Accessing database through bsh script.
>
>
> 20msec of what total? That is, what percentage is that 20msec?
>
> I'm assuming there is grouping and summary data in the query?
>
> Another important question is, how many tables, conditionals, etc?
>
> BUT... before you waste time answering my questions, the real question is
> this. Exactly what kind
> of query is Vijay trying to optimize? Always best to treat the exact problem
> encountered.
>
> Jonathon
>
> skip@theDevers wrote:
>> In my testing, there is an approximate 20msec hit using the entity engine
>> over raw jdbc, depending of course on the query, is there a seca involved,
>> etc.
>>
>> Skip
>>
>> -----Original Message-----
>> From: vijay Si [mailto:[hidden email]]
>> Sent: Saturday, September 15, 2007 10:28 AM
>> To: [hidden email]
>> Subject: Re: Accessing database through bsh script.
>>
>>
>> Jonathon
>>
>> It seems that other option left is to use a jdbc connection to database.
> Is
>> it also imperative then, that for very complex querries having
>> "groupby"..."having" and other clauses it is better to use jdbc method of
>> connection.
>>
>> How does it affect the ofbiz philosophy of architecture if i use jdbc for
>> executing these querries. As right now i cannot find any ways of
>> implementing those aggregate functions(sum,min,max...) through Entity
> Engine
>> (without creating views). Also do you have any idea of performance
> behaviour
>> on using jdbc connection?
>>
>> Thanks.
>>
>>
>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>> There's no other (easy) way to query database, aside from using the
> Entity
>>> Engine (which was what
>>> I suggested).
>>>
>>> If you're worried about performance hit with a huge (and unconditional)
>>> cross-product, see
>>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>>
>>> Jonathon
>>>
>>> vijay Si wrote:
>>>> Hi Jonathon,
>>>>
>>>> i cannot use the view-entity for querrying, as it would cause a
>>> performance
>>>> hit. Is there any other method to get the above querry. Do u know of any
>>>> ways to do it through bsh script.
>>>>
>>>>
>>>> Regards
>>>>
>>>>
>>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>>> can't recall the aggregate
>>>>> functions there.
>>>>>
>>>>> The entity definitions do have those, though. The <view-entity>? Oh
>>> yes,
>>>>> the <view-entity>.
>>>>>
>>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>>
>>>>> Jonathon
>>>>>
>>>>> vijay Si wrote:
>>>>>> Is there any funtionality provided for using aggregate functions
>>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>>
>>>>>> for egg: how can we write following in BSH :
>>>>>>
>>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>>> order_type_id="PURCHASE_ORDER";
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>> ------------------------------------------------------------------------
>>>>>> No virus found in this incoming message.
>>>>>> Checked by AVG Free Edition.
>>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>>> 9/14/2007 8:59 AM
>>>>>
>>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>> 9/14/2007 8:59 AM
>>>
>>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Accessing database through bsh script.

SkipDever
Soon as I get a minute, I'll go find the code again and post it somewhere.
But, I do recall that the results were pretty consistant from one run to the
next, and I took the numbers from an email I sent to Si which I copied and
pasted from Windows console (although for 20 instead of 2000 finds).

Again, the tests were initially just to compare SOAP and XML-RCP to get a
feel for the viability of using them in production, hence the contrived
nature of the "test case".

Skip

-----Original Message-----
From: David E Jones [mailto:[hidden email]]
Sent: Monday, September 17, 2007 2:03 AM
To: [hidden email]
Subject: Re: Accessing database through bsh script.



Are you sure about these results? The test case sounds really funny, but
however it was done if the same operations are being done with both this
sort of difference would REALLY surprise me. In the first 2-3 years of
development on entity engine I spent around 200 hours doing profiling and
optimization, and based on that the comparison to JDBC was that the entity
engine generally had around a 10-20% overhead over JDBC, and generally much
less (because compared to the network overhead the EE wrapper objects,
especially using recycled objects, has very little overhead).

It has been about 3 years since that, but I'd still be really surprised if
something has changed that significantly since then.

-David


skip@theDevers wrote:
> I did some simple tests to retrieve data back when I was doings
comparisons

> of SOAP and XML-RPC performance. This test was on the Product table with
> 2000 sequential keys and then doing a binary halving to retrieve the
> records, i.e. record 1000 first, followed by 500 and then 1500, etc (to
> overcome database caching).
>
> I did this in a loop both for
> delegator.findByAnd("Product",UtilMisc.toMap("partyId", client));
>
> and
>
> r = sStatement.executeQuery("SELECT * FROM " + DATABASENAME + " where " +
> FID + " = '" + client + "'");
>
> These ran in separate loops, one after the other and I moved the order so
> the delegrator group ran first and then second.
>
> The results were that it took an averate of 6 msecs to do the executeQuery
> call and 23 msecs to do the delegator call.
>
> Skip
>
> -----Original Message-----
> From: Jonathon -- Improov [mailto:[hidden email]]
> Sent: Sunday, September 16, 2007 3:44 AM
> To: [hidden email]
> Subject: Re: Accessing database through bsh script.
>
>
> 20msec of what total? That is, what percentage is that 20msec?
>
> I'm assuming there is grouping and summary data in the query?
>
> Another important question is, how many tables, conditionals, etc?
>
> BUT... before you waste time answering my questions, the real question is
> this. Exactly what kind
> of query is Vijay trying to optimize? Always best to treat the exact
problem
> encountered.
>
> Jonathon
>
> skip@theDevers wrote:
>> In my testing, there is an approximate 20msec hit using the entity engine
>> over raw jdbc, depending of course on the query, is there a seca
involved,

>> etc.
>>
>> Skip
>>
>> -----Original Message-----
>> From: vijay Si [mailto:[hidden email]]
>> Sent: Saturday, September 15, 2007 10:28 AM
>> To: [hidden email]
>> Subject: Re: Accessing database through bsh script.
>>
>>
>> Jonathon
>>
>> It seems that other option left is to use a jdbc connection to database.
> Is
>> it also imperative then, that for very complex querries having
>> "groupby"..."having" and other clauses it is better to use jdbc method of
>> connection.
>>
>> How does it affect the ofbiz philosophy of architecture if i use jdbc for
>> executing these querries. As right now i cannot find any ways of
>> implementing those aggregate functions(sum,min,max...) through Entity
> Engine
>> (without creating views). Also do you have any idea of performance
> behaviour
>> on using jdbc connection?
>>
>> Thanks.
>>
>>
>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>> There's no other (easy) way to query database, aside from using the
> Entity
>>> Engine (which was what
>>> I suggested).
>>>
>>> If you're worried about performance hit with a huge (and unconditional)
>>> cross-product, see
>>> http://www.nabble.com/forum/ViewPost.jtp?post=12590081&framed=y and
>>> https://issues.apache.org/jira/browse/OFBIZ-1232
>>>
>>> Jonathon
>>>
>>> vijay Si wrote:
>>>> Hi Jonathon,
>>>>
>>>> i cannot use the view-entity for querrying, as it would cause a
>>> performance
>>>> hit. Is there any other method to get the above querry. Do u know of
any

>>>> ways to do it through bsh script.
>>>>
>>>>
>>>> Regards
>>>>
>>>>
>>>> On 9/15/07, Jonathon -- Improov <[hidden email]> wrote:
>>>>> Use the GenericDelegator and related classes, I think. Or maybe not. I
>>>>> can't recall the aggregate
>>>>> functions there.
>>>>>
>>>>> The entity definitions do have those, though. The <view-entity>? Oh
>>> yes,
>>>>> the <view-entity>.
>>>>>
>>>>> Try using DynamicViewEntity to construct a <view-entity>.
>>>>>
>>>>> Jonathon
>>>>>
>>>>> vijay Si wrote:
>>>>>> Is there any funtionality provided for using aggregate functions
>>>>>> (sum,min,max..) and count()  for querrying to data base through bsh.
>>>>>>
>>>>>> for egg: how can we write following in BSH :
>>>>>>
>>>>>> Select sum(order_id),sum(grand_total) from order_header  where
>>>>>> order_type_id="PURCHASE_ORDER";
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>> ------------------------------------------------------------------------
>>>>>> No virus found in this incoming message.
>>>>>> Checked by AVG Free Edition.
>>>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>>>> 9/14/2007 8:59 AM
>>>>>
>>>>>
>>>> -----------------------------------------------------------------------
-

>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.487 / Virus Database: 269.13.19/1008 - Release Date:
>>> 9/14/2007 8:59 AM
>>>
>>>
>>
>
>