Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Devel

SearchBuilder and sorting in Oracle

 

 

Request Tracker devel RSS feed   Index | Next | Previous | View Threaded


SO at schilling

Feb 12, 2009, 2:37 AM

Post #1 of 5 (1032 views)
Permalink
SearchBuilder and sorting in Oracle

Hi,

I've been struggling with CustomFields in RT not being shown in the desired order, and I have now pinpointed where the problem apparently is.

As I see it, it is Oracle's query optimizer that prevents the DistinctQuery-SQL to return the rows in correct order. I have tweaked the generated SQL in DistinctQuery (Oracle.pm) and it now seems to give the correct result (at least my CustomFields are now shown in the right order :)). You may argue, that there is an overhead in my solution (two order bys), but I do not have enough in-depth knowledge of how the whole SearchBuilder works.

Anyway - you may adopt the solution or simply use it as inspiration :)

diff DBIx-SearchBuilder-1.54/SearchBuilder/Handle/Oracle.pm Oracle.pm
275c275,283
< $$statementref = "SELECT main.* FROM ( SELECT main.id FROM $$statementref $group $order ) distinctquery, $table main WHERE (main.id = distinctquery.id)";
---
>
> $$statementref = qq [.
> SELECT main.* FROM
> ( SELECT rt_internal_table.id, rownum rt_internal_sort_order FROM
> ( SELECT main.id FROM $$statementref $group $order ) rt_internal_table
> ) distinctquery, $table main
> WHERE (main.id = distinctquery.id) order by distinctquery.rt_internal_sort_order
> ];
>

Configuration used: Perl v5.8.8, Oracle 10.2.0.1.0, RT3.8.1 and SearchBuilder 1.54

Best regards

Steen Olesen
Schilling A/S
Baldersbækvej 24-26
DK-2635 Ishøj
Tel: +45 70 27 99 00
Fax: +45 70 27 99 10
Mailto:so [at] schilling<mailto:so [at] schilling>
http://www.schilling.dk<http://www.schilling.dk/>


jesse at bestpractical

Feb 12, 2009, 9:50 AM

Post #2 of 5 (970 views)
Permalink
Re: SearchBuilder and sorting in Oracle [In reply to]

Steen, I've bounced this into the RT bugs queue for evaluation. Thanks!


On Thu 12.Feb'09 at 11:37:02 +0100, Steen Olesen wrote:
> Hi,
>
>
>
> I've been struggling with CustomFields in RT not being shown in the
> desired order, and I have now pinpointed where the problem apparently is.
>
>
>
> As I see it, it is Oracle's query optimizer that prevents the
> DistinctQuery-SQL to return the rows in correct order. I have tweaked the
> generated SQL in DistinctQuery (Oracle.pm) and it now seems to give the
> correct result (at least my CustomFields are now shown in the right order
> J). You may argue, that there is an overhead in my solution (two order
> bys), but I do not have enough in-depth knowledge of how the whole
> SearchBuilder works.
>
>
>
> Anyway - you may adopt the solution or simply use it as inspiration J
>
>
>
> diff DBIx-SearchBuilder-1.54/SearchBuilder/Handle/Oracle.pm Oracle.pm
>
> 275c275,283
>
> < $$statementref = "SELECT main.* FROM ( SELECT main.id FROM
> $$statementref $group $order ) distinctquery, $table main WHERE (main.id =
> distinctquery.id)";
>
> ---
>
> >
>
> > $$statementref = qq [
>
> > SELECT main.* FROM
>
> > ( SELECT rt_internal_table.id, rownum rt_internal_sort_order FROM
>
> > ( SELECT main.id FROM $$statementref $group $order ) rt_internal_table
>
> > ) distinctquery, $table main
>
> > WHERE (main.id = distinctquery.id) order by
> distinctquery.rt_internal_sort_order
>
> > ];
>
> >
>
>
>
> Configuration used: Perl v5.8.8, Oracle 10.2.0.1.0, RT3.8.1 and
> SearchBuilder 1.54
>
>
>
> Best regards
>
>
>
> Steen Olesen
> Schilling A/S
> Baldersbækvej 24-26
> DK-2635 Ishøj
> Tel: +45 70 27 99 00
> Fax: +45 70 27 99 10
> [1]Mailto:so [at] schilling
> [2]http://www.schilling.dk
>
> References
>
> Visible links
> 1. mailto:so [at] schilling
> 2. http://www.schilling.dk/

> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel


--


sturner at MIT

Feb 12, 2009, 9:58 AM

Post #3 of 5 (979 views)
Permalink
Re: SearchBuilder and sorting in Oracle [In reply to]

On Thu, 12 Feb 2009 12:50:15 -0500, Jesse Vincent
<jesse [at] bestpractical> wrote:

> Steen, I've bounced this into the RT bugs queue for evaluation. Thanks!
>
>

There was some discussion about this last year:

http://www.gossamer-threads.com/lists/rt/devel/75666

Steve

--
Stephen Turner
Senior Programmer/Analyst - SAIS
MIT IS&T
_______________________________________________
List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel


SO at schilling

Feb 12, 2009, 12:46 PM

Post #4 of 5 (977 views)
Permalink
Re: SearchBuilder and sorting in Oracle [In reply to]

Hi Steve,

I did look for solutions (and discussions on the subject) before trying to solve this.

It is quite obvious, that it is the Oracle query optimizer that is playing tricks.
You can run the standard DistinctQuery-SQL with:

Alter session set optimizer_mode=choose;
* Get one result
Alter session set optimizer_mode=all_rows;
* Get another result
Alter session set optimizer_mode=rule; // I know - this is not supported :)
* Get a third result.

/Steen

________________________________________
Fra: rt-devel-bounces [at] lists [rt-devel-bounces [at] lists] P&#229; vegne af Stephen Turner [sturner [at] MIT]
Sendt: 12. februar 2009 18:58
Til: Jesse Vincent; Steen Olesen
Cc: rt-devel [at] lists
Emne: Re: [Rt-devel] SearchBuilder and sorting in Oracle

On Thu, 12 Feb 2009 12:50:15 -0500, Jesse Vincent
<jesse [at] bestpractical> wrote:

> Steen, I've bounced this into the RT bugs queue for evaluation. Thanks!
>
>

There was some discussion about this last year:

http://www.gossamer-threads.com/lists/rt/devel/75666

Steve

--
Stephen Turner
Senior Programmer/Analyst - SAIS
MIT IS&T
_______________________________________________
List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
_______________________________________________
List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel


sturner at MIT

Feb 12, 2009, 1:50 PM

Post #5 of 5 (971 views)
Permalink
Re: SearchBuilder and sorting in Oracle [In reply to]

On Thu, 12 Feb 2009 15:46:21 -0500, Steen Olesen <SO [at] schilling> wrote:

> Hi Steve,
>
> I did look for solutions (and discussions on the subject) before trying
> to solve this.
>
>
> /Steen
>

Hi Steen,

Sure - I just wanted to make sure that BP was aware of the previous
discussion -

Thanks,
Steve

--
Stephen Turner
Senior Programmer/Analyst - SAIS
MIT IS&T
_______________________________________________
List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel

Request Tracker devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.