Table for filters in queries
Is anyone aware of any tables which show the filters that are used in a query i.e. the infoobject that is used in the filter? Thanks
Hi Niten,
This might help you:
Intercepting fixed values launching query
Similar Messages
-
SAP Tables for Bex Jump Queries
Hello Everyone,
Need to know, is there any SAP table which stores the list of jump queries in the system.
Can you share your inputs.
Regards,
JohnThanks all for the reply. I can able to get the query name using two table rsbbsquery and rszeltdir table...but i just able to get the query tech name which i dont know whether it is a summary query name or the detail query name... so how can identify ???
I have one more follow up question with reference to the SAP table...
Lets say we are creating a jump query from summary query " Query 1 " did the jumpto config on the plant characterstic and jumping to detail query " query 2".
I would like to see the query 1 to quer 2 relationship in the table.
Do we any table which stores this information, after creating the config in RSBBS. -
Select substr from 2 tables for filtering.
I got errors when trying to use the same qualifier to read a collumn label "fdn"
from 2 tables with its content delimited as follow: Read content between the 2
dashes:
select substr(fdn,INSTR(fdn,'-',1,1)+INSTR(fdn,'-',1,2)-INSTR(fdn,'-',1,1)-1)
from ont, ontdataport;
It would work if I coded " from ont" = one table but not for both: "from ont, ontdataport". Each table does have the column "fdn".
I am new to this nested instruction ! Please help me out with a work around solution. I really appreciate your assistance.Maxim:
Here is the code from my tested database:
set feedback off
set heading off
set trimspool off
set pagesize 0
spool /tmp/OntDataPortStatus.csv
select 'IPAddress, OntId, ActiveIdentifier, UserLabel, UserLabelGroup, ONtPortId,
OperationalState' from dual;
select substr(a.fdn,INSTR(a.fdn,'-',1,1)+1,INSTR(a.fdn,'"',1,2)-INSTR(a.fdn,'-',1,1)-1)
||','||a.ontid
||','||a.activeidentifier
||','||a.userlabel
||','||b.userlabel
||','||userlabelgroup
||','||b.ontportid
||','||b.operationalstate
from ont a, ontdataport b
where substr(a.fdn,INSTR(a.fdn,'-',1,1)+1,INSTR(a.fdn,'"',1,2)-INSTR(a.fdn,'-',1,1)-1)=
substr(b.fdn,INSTR(b.fdn,'-',1,1)+1,INSTR(b.fdn,'"',1,2)-INSTR(b.fdn,'-',1,1)-1);
spool off
exit;
and the query result is:
IPAddress, OntId, ActiveIdentifier, UserLabel, UserLabelGroup, ONtPortId,
OperationalState
192.100.150.115,ONT-1,ADFB44252123,LET-2-2-1,LET-G2-1-1D,LET-G2-1,ONTDATA-1,0
192.100.150.115,ONT-1,ADFB44182000,LET-2-1-1,LET-G2-1-1D,LET-G1-1,ONTDATA-1,0
192.100.150.115,ONT-1,ADFB44252123,LET-2-2-1,LET-G1-1-1D,LET-G2-1,ONTDATA-1,0
192.100.150.115,ONT-1,ADFB44182000,LET-2-1-1,LET-G1-1-1D,LET-G1-1,ONTDATA-1,0
Because table a is the parent of table b and the desired query is 2 rows only because the other 2 are duplicates. How could I recode this? Many thanks, HM -
Issue with Multiple LTS for a fact table and filters
Hello,
I am facing an issue with obiee 10g.
In my model, I have a huge FACT table F1 (partitioned and indexed). The average response time for the queries, which targeted it, was ~30-60 seconds, which was not really convincing our end user.
So, we decided to create a materialized view, which removes some dimensions that are not used by default, but might be used if the end user adds some filters. I added the Materialized view in the Physical Layer and in the corresponding Logical Table Source.
I then tried to see if it works, but I was a bit surprised by the result. Indeed,
-> If the report does not reference a truncated dimension, it targets the materialized view. -> Perfect
-> If the report does reference a truncated dimension in the columns, it targets the Fact Table. -> Perfect
-> If the report does reference a truncated dimension in the Filters, it targets the materialized view. For this reason, the filter is never resolved and no join on the dimension table is applied, whereas it exists in logical SQL generated. -> Ko.
A suggestion could be to add the filters into the columns, but I am not satisfied by this response because it will never use the materialized view in that case.
An other suggestion could be to use query rewrite, but I 'd like to have the full control on the generation of the queries.
Does someone know if the filters are not evaluated to determine which LTS to use? How can I force this evaluation?
Regards,Hi,
If I understand your description correctly, then your materialized view skips some dimensions (infrequent ones). However, when you reference these skipped dimensions in filters, the queries are hitting the materialized view and failing as these values do not exist. In this case, you could resolve it as follows
1. Create dimensional hierarchies for all dimensions.
2. In the fact table's logical sources set the content tabs properly. (Yes, I think this is it).
When you skipped some dimensions, the grain of the new fact source (the materialized view in this case) is changed. For example:
Say a fact is available with the keys for Product, Customer, Promotion dimensions. The grain for this is Product * Customer * Promotion
Say another fact is available with the keys for Product, Customer. The grain for this is Product * Customer (In fact, I would say it is Product * Customer * Promotion Total).
So in the second case, the grain of the table is changed. So setting appropriate content levels for these sources would automatically switch the sources.
So, I request you to try these settings and let me know if it works.
Thank you,
Dhar -
Create a Navigational Hierarchy for filtering with the Table API
Hello,
I've built a WAD report acourding to the how to document: "Create a Navigational Hierarchy for filtering with the Table API".
It works great but i dont know How to make the hirarchey to show the key and the text.
Please Advice.
DavidHi Kenneth,
please have a look in the source of the executed Web Application. What is inside of the <div> with the id filter?
You should also find a td tag with id hier_xyz with xyz the filter inside of the <div>-Tag with id filter.
Also check whether you have a javascript error.
Have a look on the Javascript function set_style. Perhaps you can paste it here, than I can have a look.
Heike -
Problem occured when create a tree table for master-detail view objects using SQL queries?
I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
SELECT cntr_list.SOURCE_BLOCK,
sum(
case when cntr_list.cntr_size_q = '20'
then cntr_list.cntr_qty
else 0 end ) as cntr20 ,
sum(
case when cntr_list.cntr_size_q = '40'
then cntr_list.cntr_qty
else 0 end ) as cntr40 ,
sum(
case when cntr_list.cntr_size_q = '45'
then cntr_list.cntr_qty
else 0 end ) as cntr45
FROM (
SELECT yb1.BLOCK_M as SOURCE_BLOCK,
scn.CNTR_SIZE_Q,
count(scn.CNTR_SIZE_Q) AS cntr_qty
FROM SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2
WHERE
scm.cmr_n = scn.cmr_n
AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')
OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))
AND scm.shift_mode_c = :ShiftModeCode
AND scm.end_terminal_c = :TerminalCode
AND scm.start_terminal_c = yb1.terminal_c
AND scm.start_block_n = yb1.block_n
AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n
AND scm.end_terminal_c = yb2.terminal_c
AND scm.end_block_n = yb2.block_n
AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n
AND scn.status_c not in (1, 11)
AND scn.shift_type_c = 'V'
AND scn.source_c = 'S'
GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q
) cntr_list
GROUP BY cntr_list.SOURCE_BLOCK
2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
SELECT cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,
sum(
case when cntr_list.cntr_size_q = '20'
then cntr_list.cntr_qty
else 0 end ) as cntr20 ,
sum(
case when cntr_list.cntr_size_q = '40'
then cntr_list.cntr_qty
else 0 end ) as cntr40 ,
sum(
case when cntr_list.cntr_size_q = '45'
then cntr_list.cntr_qty
else 0 end ) as cntr45
FROM (
SELECT yb1.BLOCK_M as SOURCE_BLOCK,
yb2.BLOCK_M as END_BLOCK,
scn.CNTR_SIZE_Q,
count(scn.CNTR_SIZE_Q) AS cntr_qty
FROM SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2
WHERE
scm.cmr_n = scn.cmr_n
AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')
OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))
AND scm.shift_mode_c = :ShiftModeCode
AND scm.end_terminal_c = :TerminalCode
AND scm.start_terminal_c = yb1.terminal_c
AND scm.start_block_n = yb1.block_n
AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n
AND scm.end_terminal_c = yb2.terminal_c
AND scm.end_block_n = yb2.block_n
AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n
AND scn.status_c not in (1, 11)
AND scn.shift_type_c = 'V'
AND scn.source_c = 'S'
GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q
) cntr_list
GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
3. I create a view link to create master-detail relationship for these 2 view objects.
masterview.SourceBlock (1)->detailview.SourceBlock (*).
4. I create a tree table using these 2 view objects with master-detail relationship.
When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
Managed Bean:
DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
ViewObject vo = dc.getViewObject();
System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo.executeQuery();
System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
ViewObject vo1 = dc1.getViewObject();
System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo1.executeQuery();
System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
5. What's wrong in my implementation? I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.Hi Frank,
Thank you and it can work.
public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
Number highSalary) {
Row r = getCurrentRow();
if (r != null) {
RowSet rs = (RowSet)r.getAttribute("EmpView");
if (rs != null) {
ViewObject accessorVO = rs.getViewObject();
accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
executeQuery();
but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and I have to change current row manually like below.
any idea?
DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
ViewObject vo = dc.getViewObject();
vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo.executeQuery();
vo.setCurrentRowAtRangeIndex(0);
((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues(); -
Table for model characteristic usage in queries
Hi does anyone know the name of the table(s) which I can establish the following:
1. I have a multicube with say 15 dimensions consisting of a total of 35 Dimension characteristics
2. There are say 6 navigational attributes switched on for reporting
3. There are say 10 key figures
4. There are say 65 queries built off this info provider
What I would like to establish is in the 65 queries which elements in 1, 2 and 3 have been used. I am aware of the RSZ* tables but was not able to find what I am looking for. Thanks in advanceHi Anand,
I find this is relevant to your query and go through this...
The names of the structural components are language dependent. When you define and save a query with the logon language as German, only the corresponding German texts are saved in the relevant tables (for example, RSZELTTXT). This is not the original key figure, but rather a structural component, a new object that linksto the original key figure but is not the original key figure.
· If you then execute the query in a different logon language to the one that you used to define the query, the standard texts are displayed for all structural components that have no text.
· Structures and structural components (selections, formulas) are completely independent objects that appear in the BEx Query Designer and that you can store in the relevant tables when you save them. Since texts are fundamentally language-dependent, the texts in the query definition appear in the logon language only when you save the query.
regards,
rudra.
Assign points if helpful... -
ADF Updating bindings for filtered rows in table
I have an ADF UIX table with say 10 rows each row having 8 fields. 2 of these are editable. So 6 fields use uix.current.fieldname and 2 editable use bindings.fieldname.
I have a drop down list on top of the table. Selecting an option fires an event which sets parameters in the view and filters the table and reduces the rows say to 4.
The table is now showing correct values for the non editable fields. But the editable fields are not showing the correct value. They show the older first four rows values.
How do I update the bindings when I reexecute the view for filtering the rows?
Appreciate your help.
Thanks,There is absolutly no reason to use PL/SQL (e.g. nested cursors, logic etc.) use MERGE
MERGE INTO emp target
USING (SELECT emp.empno,emp.sal,dept.dname,
CASE WHEN dept.dname ='ACCOUNTING'
THEN TRUNC(emp.sal * 1.2) ELSE TRUNC(emp.sal * 1.1) END new_sal
FROM emp
INNER JOIN dept
ON (emp.deptno = dept.deptno)
)source
ON (target.empno = source.empno)
WHEN MATCHED THEN UPDATE
SET target.sal = source.new_sal;And, if the factor of the update is stored in a special table / query, it gets even easier to maintain.
-- andy -
Run queries against system tables for oracle BPEL processes
I want to run queries against system tables for oracle BPEL processes. It is becoming very difficult for me to us EM as it is very slow,
and not all the time, it is sufficient for our needs.
We are doing load testing and we want find out info like how many requests came in and how many faulted and what time is taken by each request...
So do any of you have the query that I can use and tables that I need to go against?Use the BPEL hydration database table "cube_instance".
There should be plenty of example in the forum regarding this table. -
Table for following the Stock Tracking in queries
hello,
I am trying to generate a query based on the stock taking module (under Inventory Transactions).
the form takes its values from different tables, but i would like to you the 'counted' column in a query.
a similar form is the price list and for price list there are tables ITM1 etc..
is there any table to take the 'counted' values from?
i'll be thankful for any help
SaarHi Jitin.
thanks for the reply.
i checked the IQR1 but it seems to be a table for inventory posting after reconciliation.
can you guide me how to find the object type of inventory tracking (a step before)?
regards
Saar -
In which tables BEx Filters parameters stored in?
Hi, gurus!
Can you tell me, in which tables I can find BEx filters parameters? E.g. I would like to find in which filters we are using variable V as a restriction of char C?
By the way, maybe someone could tell me IP analog of the BPS table UPC_FORML? I mean where could I find every texts of our IP FOX formulas?Hi Mikhail,
You can get BEx filter param for characteristics from table rszrange. You will get element ID's of restrictions from this table for each characteristic restriction. You will then have to take these ELTUIDs and put them in table rszeltxref to get COMPUIDs for queries for the aforementioned restrictions. Then, you can get query tech names from RSRREPDIR for these COMPUIDs.
Hope it helps.
Thanks,
Abhishek. -
Disabling button if table is filtered
hi,
i have a command button and a adf table on a jspx page.
i am keeping filtering enabled for table.
my requirement is i have to disable button if table is filtered and as soon as table becomes 'normal' or 'un filtered' i should enable this button.
can anyone suggest a way to implement this use case?
thanks.Don Kleppinger wrote:
Just add a query listener to the table which gets called whenever query is filtered. Detect if the list of filter criteria is empty and refresh your button accordingly
public void queryListener(QueryEvent queryEvent)
FilterableQueryDescriptor desc = (FilterableQueryDescriptor) queryEvent.getDescriptor();
Map<String, Object> filterCriteria = desc.getFilterCriteria();
// refresh your button here.
// call default query listener to execute the query
Object query = JSFUtils.resolveExpression("#{bindings.MyROViewQuery}");
((FacesCtrlSearchBinding) query).processQuery(queryEvent);
to avoid using the internal FacesCtrlSearchBinding class use the example from
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/30-table-filter-queries-169172.pdf
invokeMethodExpression(
"#{bindings.DepartmentsView1Query.processQuery}",
Object.class,QueryEvent.class,queryEvent);
Edited by: Don Kleppinger on Jun 4, 2013 12:02 PMthanks Don.
on this -
Detect if the list of filter criteria is empty and refresh your button accordingly
to detect i am using this code:
boolean filterApplied = false;
while (iterator.hasNext()) {
String key = iterator.next().toString();
String value = filterCriteria.get(key).toString();
if (!value.isEmpty()) {
filterApplied = true;
break;
System.out.println("filterApplied --> " + filterApplied);
is there anyway better way of detecting?
Edited by: user5636757 on Jun 6, 2013 10:46 AM -
Standard table for finding query where used list
Are there any standard tables available to find the list of web templates, bex reports and views using a particular query?
i.e if i have the query name i should be able to find out where all it is being used.
Thanks,
ArchnaHello,
You have to join multiple tables to achieve this, here we go
FOR QUERY Related Information
RSRREPDIR - Directory of all reports (Query GENUNIID)
Choose Type of a reporting component -> REP
Tips :
Choose Type of a reporting component -> QVW for query view
SE11 -> RSZ* -> F4 gives you all tables related to queries
For WORKBOOK Related Information
Use the FM RRMX_WORKBOOK_QUERIES_GET to get the queries in a workbook by selecting the workbook ID from table RSRWORKBOOK
Tips :
SE11 -> RSRWB* -> F4 gives you all tables related to workbooks
SE37 ->RRMX_WORKBOOKS* -> F4 gives you all the FM related to workbooks
For Webtemplate Related Information
Choose the dataprovider for query / view ID.
SE11 -> RSZWOBJXREF - Structure of the BW Objects in a Template
Also see,
SE11 - > RSZWTEMPLATE - Header Table for BW HTML Templates
Thanks
Chandran -
Table for finding out the User details
Hi All,
We need to create a KPI for number of hours a user has looged into a system. Is there any specific table where all the user related information is captured.If the information is not present in a table where can we find the above information?Please someone help me out.....
Also is it the same in all the systems or does this information differ from system to system?If it differs then how do we find the number of hours a user has logged in for a BW system, for a CRM system and for ECC system?
Regards,
ShravaniHello,
USR01User master record (run-time data)
USR02 Logon data
USR03 User address data
USR04 User master authorizations
USR05 User Master Parameter ID
USR06 Additional data per user
USR07 Object/values of last failed authorization check
USR08 Table for user menu entries
USR09 Entries for user menus (work areas)
USR10 User master authorization profiles
USR11 User Master Texts for Profiles (USR10)
USR12 User master authorization values
USR13 Short Texts for Authorizations
USR14 Surchargeable language versions per user
USR15 External User Name
USR20 Date of last user master reorganization
USR30 Additional Information for User Menu
USR40 Table for illegal passwords
USR41 User master: Additional data
USRCOBJ Object Filters for Exploding Product Structures
USRM0 Material Master User Settings: User Screen Reference
USRM1 Material Master User Settings: Organizational Levels
USRM2 Material Master User Settings: Logical Screens
USRMM User settings: material master
Might be these can help you.
Thanks
Geeta -
Is rank() really better than rownum for top-n-queries?
Several sources say that for Oracle databases rank() should be used instead of 'rownum <= n' for top-n-queries. But here we have an application, where we a lot of top-n queries are executed on a big table with several million rows and rank() has a quite bad performance. I get much better results when I use a query with rownum <= n but the programmer of the application doesn't want to change it in the software because of those articles about rank() and rownum. I wonder, whether it is possible, to find a better form of the rank()-query or an additional index, that gives me the same performance.
To explain my case I created the following example (if you try it, be aware that depending on the size of your dba_objects view you might need up to half a gig free space in your tablespace for this example).
create table big_objects
as
select
ascii(m.alpha)*100000+o.object_id object_id,
o.owner owner,
o.object_type,
m.alpha||'_'||o.object_name object_name,
sysdate-400+mod(100*object_id+99*ascii(m.alpha),365)+24/(o.object_id+ascii(m.alpha)) created,
o.status
from
(select distinct
upper(substr(object_name,1,1)) alpha
from
sys.dba_objects
where
upper(substr(object_name,1,1)) between 'A' and 'Z') m,
sys.dba_objects o
order by
object_name;
create index bigindex_1 on big_objects (owner, object_type, created);
analyze table big_objects compute statistics;
So my table looks a bit like dba_objects but with much more rows and I made a synthetic "created" date which is more similar to my real case, where top-n means a date selection of the newest records from a certain type.
Here is the size of the segments on an nearly empty 11gR2 database:
select segment_name, bytes, blocks from sys.dba_segments where segment_name like 'BIG%'
SEGMENT_NAME BYTES BLOCKS
BIGINDEX_1 75497472 9216
BIG_OBJECTS 142606336 17408
On my database the example table has approx. 1,9 Mio rows:
select count(*) from big_objects;
COUNT(*)
1884246
and some 1,4% of those rows have owner = 'SYS' and object_type = 'INDEX'
select
count(*)
from big_objects
where owner = 'SYS'
and object_type = 'INDEX';
COUNT(*)
25896
But I want to find only the 10 newest indexes for the owner SYS. I think the typical rank() approach would be:
select
owner,
object_type,
object_name,
object_id,
status,
created
from
( select
owner,
object_type,
object_name,
object_id,
status,
created,
rank() over (order by created desc) rnk
from
big_objects
where
owner = 'SYS'
and object_type = 'INDEX')
where rnk <= 10
order by created asc;
OWNER OBJECT_TYPE OBJECT_NAME OBJECT_ID STATUS CREATED
SYS INDEX B_COLLELEMIND 6600515 VALID 15.04.2010 19:05:55
SYS INDEX V_I_WRI$_OPTSTAT_IND_OBJ#_ST 8600466 VALID 15.04.2010 19:09:03
SYS INDEX G_I_RLS 7100375 VALID 15.04.2010 19:23:55
SYS INDEX V_I_DIR$SERVICE_UI 8600320 VALID 15.04.2010 19:31:33
SYS INDEX L_I_TSM_DST2$ 7600308 VALID 15.04.2010 19:36:26
SYS INDEX L_I_IDL_UB11 7600235 VALID 15.04.2010 19:57:34
SYS INDEX V_I_VIEWTRCOL1 8600174 VALID 15.04.2010 20:19:21
SYS INDEX L_I_TRIGGER2 7600162 VALID 15.04.2010 20:31:39
SYS INDEX L_I_NTAB1 7600089 VALID 15.04.2010 21:35:53
SYS INDEX B_I_SYN1 6600077 VALID 15.04.2010 22:08:07
10 rows selected.
Elapsed: 00:00:00.22
Execution Plan
Plan hash value: 2911012437
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1427 | 188K| 1400 (1)| 00:00:17 |
| 1 | SORT ORDER BY | | 1427 | 188K| 1400 (1)| 00:00:17 |
|* 2 | VIEW | | 1427 | 188K| 1399 (1)| 00:00:17 |
|* 3 | WINDOW SORT PUSHED RANK | | 1427 | 79912 | 1399 (1)| 00:00:17 |
| 4 | TABLE ACCESS BY INDEX ROWID| BIG_OBJECTS | 1427 | 79912 | 1398 (0)| 00:00:17 |
|* 5 | INDEX RANGE SCAN | BIGINDEX_1 | 1427 | | 9 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("RNK"<=10)
3 - filter(RANK() OVER ( ORDER BY INTERNAL_FUNCTION("CREATED") DESC )<=10)
5 - access("OWNER"='SYS' AND "OBJECT_TYPE"='INDEX')
Statistics
1 recursive calls
0 db block gets
25870 consistent gets
0 physical reads
0 redo size
1281 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
10 rows processed
As from the index only the first two columns are used, all the 25896 records that I found above are read and sorted just to find the ten newest ones. Many unnecessary blocks are read and luckily all needed database blocks were in memory already. In our real case quite often a lot of physical reads are performed, which makes the performance of the application even worse.
In my following example with a "rownum <= 10" all three columns of the index are used and the number of block gets is much, much smaller than in the rank() example.
select
owner,
object_type,
object_name,
object_id,
status,
created
from
big_objects
where
(owner, object_type, created)
in
( select
owner,
object_type,
created
from
( select /*+ first_rows(10) */
owner,
object_type,
created
from
big_objects
where
owner = 'SYS'
and object_type = 'INDEX'
order by
owner,
object_type,
created desc
where rownum <= 10
order by created asc;
OWNER OBJECT_TYPE OBJECT_NAME OBJECT_ID STATUS CREATED
SYS INDEX B_COLLELEMIND 6600515 VALID 15.04.2010 19:05:55
SYS INDEX V_I_WRI$_OPTSTAT_IND_OBJ#_ST 8600466 VALID 15.04.2010 19:09:03
SYS INDEX G_I_RLS 7100375 VALID 15.04.2010 19:23:55
SYS INDEX V_I_DIR$SERVICE_UI 8600320 VALID 15.04.2010 19:31:33
SYS INDEX L_I_TSM_DST2$ 7600308 VALID 15.04.2010 19:36:26
SYS INDEX L_I_IDL_UB11 7600235 VALID 15.04.2010 19:57:34
SYS INDEX V_I_VIEWTRCOL1 8600174 VALID 15.04.2010 20:19:21
SYS INDEX L_I_TRIGGER2 7600162 VALID 15.04.2010 20:31:39
SYS INDEX L_I_NTAB1 7600089 VALID 15.04.2010 21:35:53
SYS INDEX B_I_SYN1 6600077 VALID 15.04.2010 22:08:07
10 rows selected.
Elapsed: 00:00:00.03
Execution Plan
Plan hash value: 3360237620
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 10 | 760 | 17 (0)| 00:00:01 |
| 1 | SORT ORDER BY | | 10 | 760 | 17 (0)| 00:00:01 |
| 2 | NESTED LOOPS | | | | | |
| 3 | NESTED LOOPS | | 10 | 760 | 17 (0)| 00:00:01 |
| 4 | VIEW | VW_NSO_1 | 10 | 200 | 2 (50)| 00:00:01 |
| 5 | HASH UNIQUE | | 10 | 200 | 4 (25)| 00:00:01 |
|* 6 | COUNT STOPKEY | | | | | |
| 7 | VIEW | | 11 | 220 | 3 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN DESCENDING| BIGINDEX_1 | 1427 | 28540 | 3 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | BIGINDEX_1 | 3 | | 2 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID | BIG_OBJECTS | 3 | 168 | 6 (0)| 00:00:01 |
Predicate Information (identified by operation id):
6 - filter(ROWNUM<=10)
8 - access("OWNER"='SYS' AND "OBJECT_TYPE"='INDEX')
9 - access("OWNER"="OWNER" AND "OBJECT_TYPE"="OBJECT_TYPE" AND "CREATED"="CREATED")
Statistics
1 recursive calls
0 db block gets
26 consistent gets
0 physical reads
0 redo size
1281 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
10 rows processed
I made this comparison with the Oracle versions 10.2 and 11.2 and the result was more or less the same. How can I change the rank() query in a way that only the small number of really needed blocks are read from the database?this was exactly the hint, I was looking for. Generally speaking hints are not the preferred way to go to tune queries. They can have nasty side-effects when data changes.
Now the rank()-query is similar fast and much better to read than my fast one with three nested SELECTs.
Your rownum query was needlessly complicated, and could be simplified to:
select owner, object_type, object_name, object_id, status, created
from (select owner, object_type, created
from big_objects
where owner = 'SYS' and
object_type = 'INDEX'
order by created desc)
where rownum <= 10
order by created ascand very likely get the same speed.
One more question. How did you format those sql queries and results. When I copy/paste them into the editor of forums.oracle.com the format allways gets lost.To preserve formatting use {noformat}{noformat} before and after the section you want ot keep formatted. In general, if you want to see how someone generated an effect, reply to the post and hit the quote original icon. You will see all the formatting codes used in the original.
John
Maybe you are looking for
-
How many users for Lightroom 5?
Hi, can anyone tell me how many installs you can have on a single copy of Lightroom 5 (Can you have it on 2 computers at once or just 1)? Also does this differ between digital download copies and hard copies? Thanks.
-
C parser and deeply nested DTDs
Your C parser is VERY fast :-), but I am having trouble with deeply nested DTDs. I can do DTD validation for an internal DTD and a single external DTD file. My problem is with a DTD which includes other DTDs to a depth of 5 levels. I am using the C X
-
Open .cp in captivate 6.1
I have Adobe Captivate 6.0.1.240 that came with Adobe eLearning Suite 6.1. Previous forums stated that I should be able to open a .cp file in Adobe 6.0, but I am receiving an error. Do I need to download Adobe Captivate 5.5 and try to open and conv
-
Old ipod says its up to date but wont run apps without new ios. what to do?
i had a samsung galaxy player but realized that i wanted an ipod back. I got an older version one thinking that the apps would work on it but due to the ios version it wont. i cant afford a new ipod but i need these apps to work. what can i do?
-
Hi sry for my english i have a Mac Book Pro and sice the last 4 days i became this on http://img268.imageshack.us/img268/2615/img0095y.jpg Thanks for help Message was edited by: Enzo88