Estimated and actual number of rows at filtered statistics
I have query like this:
SELECT productID FROM dbo.table WHERE nar_closed=1 AND nar_status=0
I have filtered index:
CREATE NONCLUSTERED INDEX [x_status] ON [dbo].[Table]
(nar_status ASC)
INCLUDE(productID)
WHERE nar_closed=1
In execution plan I can see that there is index seek - so optimal plan. But, estimated number of rows is 1716930 and actual number of rows is only 63260. How is that possible? I have rebuild index and statistic is up to date. Statistic is also filtered(like
index). Is there some problem with filtered statistics?
What should i do, to get actual and estimated number of rows similar?
I'm usually busy Monday night, but it turned that I got this one off.
SELECT @productID=i.item_id
FROM dbo.order_item i INNER JOIN dbo.order_header h ON i.header_id = h.header_id
WHERE i.last_item=1 AND i.item_finished=0 AND h.order_status IN(1,2,3) OPTION (MAXDOP 1, RECOMPILE)
So this is a different query from which I looked at during the weekend. Yes, you get incorrect estimates, but there is a simple reason for this. Look this query:
SELECT h.order_status, COUNT(*)
FROM order_header h
JOIN order_item i ON i.header_id = h.header_id
GROUP BY h.order_status
ORDER BY h.order_status
The output is:
order_status
0 434
1 4
2 357231
4 2311649
But look at:
SELECT h.order_status, COUNT(*)
FROM order_header h
JOIN order_item i ON i.header_id = h.header_id
WHERE i.last_item = 1
AND i.item_finished = 0
GROUP BY h.order_status
ORDER BY h.order_status
This produces:
order_status
0 76
1 4
2 63179
4 1
You have a skew. There is big correlation between having a row with item_last = 1 and item_finished = 0 and order_status = 2. Which you probably knew already. But SQL Server has no clue!
I was trying to figure out exactly how it arrived at that number, but SQL Server may be smarter than me, because my computations landed at even lower numbers.
Dealing with skews is often difficult, and you tend to end up with tricks, some uglier than others. I tried adding this filtering statistics on order_item:
CREATE STATISTICS order_item.header_filter_stat ON
order_item(header_id) WHERE last_item = 1 AND item_finished = 0
WITH FULLSCAN
But that lowered the estimate even more! If I drop the filter index ix_last, I get a Merge Join, wich only has a 50% misestimate, but I suspect that it does not give better performance. (The data volume is not significant to tell.)
I'm not concered about memory grant but with number of estimated rows.
But your concern was hash spill, and hash spill occurs because the memory grant is too low, and it is low due to the low row estimate.
Erland, I'm assigning to the varibale just for the sake of example - to get rid of table result set.
But since the query is logically different, the optimizer could produce a different plan. It does not seem to make that shortcut, but you never know. When I don't want to see the result set, I usually use SELECT INTO.
Erland Sommarskog, SQL Server MVP, [email protected]
Similar Messages
-
Adding estimation and actual time information to SLFN tickest
Hello,
We want to track some basic information about estimation and actual work done in any single ticket. So, we want to add some fields such as:
- Number of estimated consulting and programming hours for each ticket
- Number of actual consulting and programming hours for each ticket.
Then we want to report on them.
Is there any easy way to do it?? Can we use "products"? Can someone provide some help in setting up this information??
Regards
Esteban HartzsteinHello,
This is something you can try.
Go to customizing:
SAP solution manager / configuration / Scenario specific settings / service desk / service desk / general settings / set up the original screen profile
Find the combination of screen profile type / transaction type = SRVO / SLFN
Change the screen profile to SRV_SLFN_2.
Go to transaction CRMD_ORDER, and create a message of type SLFN.
You will now notice that a button shows up called 'item details' between the fast entry and transaction data buttons.
Click on it.
There you can add your products, maybe one for planned time and one for actual time (remember to put the actual time before closing the message)
These fields will show in transaction CRM_DNO_MONITOR.
if you need to create products you transaction COMMPR01 and if you need to create product hierarchies use COMM_HIERARCHY.
Rgds. -
XMLIndex: finding indexed XPaths and the number of rows in the path table
Hi,
I am storing non-schema-based binary XMLs in an XMLType column in 11g (11.1.0.6.0) and would like to index the XMLs either partially or fully using XMLIndex. I'm expecting to have a large number (tens of millions) of XML documents and have some concerns about the size of the XMLIndex path table.
In short, I am worried that the path table might grow unmanageable large. In order to avoid this and to plan for table partitioning, I would like to create a report of all indexed XPaths in an XMLIndex and to find out how many times each path is actualized in the path table. I would do this for a representative XML sample.
I have been creating XMLIndexes with different exclude/include paths, gathering stats with DBMS_STATS (estimate_percent = 100) and selecting the number of rows in the path table through USER_TABLES.
If anyone knows a more straightforward way of doing this all advice is very much appreciated.
Best Regards,
Rasko LeinonenThanks Marco,
I managed to get out all indexed paths using the following SQL. It took a while to understand how the join the XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5 and XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5 tables together but got there in the end. This helps to clarify which XPaths are being currently indexed by the XMLIndex.
begin
for v_row in (select PATH from XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5)
loop
declare
v_i BINARY_INTEGER := 1;
v_id raw(8);
v_len BINARY_INTEGER := 2;
v_skip BINARY_INTEGER := 1;
begin
while v_i < utl_raw.length(v_row.path) and
v_i + v_len <= utl_raw.length(v_row.path)
loop
v_i := v_i + v_skip;
v_id := utl_raw.substr(v_row.path, v_i, v_len);
--dbms_output.put_line(v_id);
for v_row2 in (select LOCALNAME, flags from XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5
where ID = v_id )
loop
if rawtohex(v_row2.flags) = '01'
then
dbms_output.put('@');
end if;
dbms_output.put(v_row2.localname);
if v_i + v_len < utl_raw.length(v_row.path)
then
dbms_output.put('/');
end if;
end loop;
v_i := v_i + v_len;
end loop;
dbms_output.put_line('');
end;
end loop;
end;
Example output:
RUN
RUN/@accession
RUN/@alias
RUN/@instrument_model
RUN/@run_date
RUN/@run_center
RUN/@total_data_blocks
RUN/EXPERIMENT_REF
RUN/EXPERIMENT_REF/@accession
RUN/EXPERIMENT_REF/@refname
RUN/DATA_BLOCK
RUN/DATA_BLOCK/@name
RUN/DATA_BLOCK/@total_spots
RUN/DATA_BLOCK/@total_reads
RUN/DATA_BLOCK/@number_channels
RUN/DATA_BLOCK/@format_code
RUN/DATA_BLOCK/@sector
RUN/DATA_BLOCK/FILES
RUN/DATA_BLOCK/FILES/FILE
RUN/DATA_BLOCK/FILES/FILE/@filename
RUN/DATA_BLOCK/FILES/FILE/@filetype
RUN/RUN_ATTRIBUTES
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/TAG
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/VALUE -
How to set number of rows in filters?
Hi, we need to set another number of rows which is displayed in filters on bex or web template?
Thanks for adviceHi Pavel,
can you please specify your question more clearly. If you are on NW 7.0 you can determine a number of colums for your filter item with following command:
COLUMNS
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/85/08e241aa8e9d39e10000000a155106/content.htm
If you meant the amount of rows within the analysis item you can use following command within your analysis item:
BLOCK_ROWS_SIZE (numbers of rows displayed at once)
BLOCK_ROWS_STEP_SIZE (numbers of rows to be scrolled for one step)
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/76/489d39d342de00e10000000a11402f/content.htm
Brgds,
Marcel
Edited by: Marcel Landsfried on Feb 10, 2009 7:45 PM
Edited due to wrong url -
Dynamic Input form with PLAN and Actual Confusion (YEAR-row / MONTH-Column)
Hi Guru's,
Assume that
Row Axis: YEAR
Column Axis: MONTH
Page Axis: VERSION
From the VERSION dimension, we re able to get Budget Year and the latest Actual Month.
For example, As u see below, the budget year is 2014 and we retreive + or - 2 years of budget year which is 2014.
And the latest actual month is Jun.
So is it possible to make a dynamic report that can retreive actual data for the budget year and latest actual month of selected VERSION and also rest of the cells should be inputtable.
By the way, we have a dimension which named as for the PLAN , ACTUAL etc.
So what do you suggest for that case? Is there any way to handle without VBA?
Thanks to all in adv.
MONTH / YEAR
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2012
2013
2014
2015
2016Hi Sadi,
I agree Vadim, you do not need extra dimension for time. You can "report" in Bex analyzer with this format but BPC reporting/input schedules is not dynamic enough. Because you can not use property in axis but in Bex it is possible. Maybe you can change input form design because where is other contex in your form, 2012.01 what, price or stocks or sth? You have to specify account and entity. I think it is useless design to input data. I added figure for sales model. In this figure, you can manage actual / budget with "if" and "today" excel formulas. And you can easily link your olap member in column axis. I think it will help you.
Best regards
Haşim. -
List Table names and number of rows in it
Following is a piece of code that would list all tables in a schema and the number of rows in each table.Hope it is helpful for you.
Note: In this example iam selecting only those tables starting with 'T_'. you may replace it accordingly.
create or replace procedure count_lines is
cursor cur is select tname from tab where tname like 'T\_%' escape '\';
lines number;
begin
dbms_output.put_line(rpad('TABLE_NAME',65,' ')||'NUMBER_OF_LINES');
dbms_output.put_line(rpad('-',80,'-'));
for i in cur loop
execute immediate 'select count(*) from '||i.tname into lines;
dbms_output.put_line(rpad(i.tname,70,' ')||lines);
end loop;
end count_lines;
Following is the sample output:(ignore alignment here)
TABLE_NAME NUMBER_OF_LINES
T_FR_ACTION 3
T_FR_ATTRIBUTE 52
T_FR_ATTRIBUTE_TYPE 3
T_FR_ATTRIBUTE_VALUE 5389This has been covered many times, so your solution is not the only way...
http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
Re: count rows in shema tables
And there's many more if you search -
Number of rows in last fetch when array festching?
Hi!
I know it must be somewhere, but I'm unable to find it in the documentation:
In OCI 8.1 how can I get the actual number of rows fetched in the last call to OCIStmtFetch() when array fetching?
E. g. when I have a buffer that can hold 100 column values and the select statement returns 140 rows, the second call to OCIStmtFetch() will only fill 40 items into the buffer. So the code processing the fetched rows should only iterate to 40 and not to 100. Is there a way to get this number with OCIGetAttr()?here's an example -
orc = OCIAttrGet((dvoid *) stmthp_cur, (ub4) OCI_HTYPE_STMT,
(dvoid *) &rows, (ub4 *) &sizep, (ub4)OCI_ATTR_ROWS_FETCHED,m_errhp); -
Interactive report - default number of rows
I am using APEX 3.1.1 and can not find a way to change the default of 15 for the "number of rows" returned when initially displaying an interactive query. Have I missed something?
It is certainly easy enough using "Layout and Pagination - Number of Rows" for a non-interactive report region.
thanks PeterHi Peter,
In the report definition, there is a section headed Default Report Settings. This shows the instruction:
To create default report settings, run the report as a developer, modify the settings (like hiding columns, adding filters, etc.), select Save Report from the Actions Menu and then save As Default Report Settings.
The default row count is one of those settings - make sure you Run the report before saving.
Andy -
How to get the number of rows in a HTML table in some other page
Hi,
I am incrementing HTML table rows on button click and saving number of rows in a javascript variable. But on submitting that page I need that number of row value in the following page
example:
HTML table is in the page first.jsp
and the javascript variable having the current row number is row_number
on submitting it goes to second.jsp page. There i need that row_number value.
Can anyone help me to solve this?
regards,
carryfunction buttonClick()
var table = profileTable;
var lnRow = table.rows.length;
var insertedRow = table.insertRow(parseFloat(lnRow));
var cell1 = insertedRow.insertCell();
cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt"+></td></tr>";
document.profileform.submit;
on submit it goes to the second page, but the value i got using >>>System.out.println("row number from text >>>box"+request.getParameter("rowNum")); is null. What is wrong with >>>my coding. Can anyone solve this.HI carry
Check the value of bold data
function buttonClick()
var table = profileTable;
var lnRow = table.rows.length;
var insertedRow = table.insertRow(parseFloat(lnRow));var cnt=inRow
var cell1 = insertedRow.insertCell();
cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt+"></td></tr>";
document.profileform.submit;
}try with it -
Create spreadsheet file with a fixed number of rows
What is the most straight forward way to create a series of spreadsheet files each with a new file name and fixed number of rows. We have a data acquisition process that creates a new 1D array every 2 seconds. We'd like to build a series of spreadsheet files each having two hours or 3600 rows of data. Is there a best way to do this in LV9?
johnUse the low-level FileI/O Vis with Write to Text File.vi where you open a new file with every N iteration like this:
You just have to convert your 1D Array to string before.
If you would like to have a new file every N hours you should create a FGV which checks the elapsed time using Get Date/Time in Seconds.vi, which is more appropriate for longtime applications.
Christian -
JDBC Sender Adapter - Restrict number of rows fetched, Oracle
Hi,
Is it possible to restrict the number of rows fetched by the JDBC Sender adapter at each run? What would the appropriate Select and Update statements be to make sure a limited number of rows are selected and flagged as processed?
We are connecting to a Oracle RDBMS.
//Johanhi,
have a look at this info:
about oracle and limiting number of rows
http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
Restrict number of rows in table view
Can a table view has only as many rows as the actual rows in the underlying data structure. Actually, I have a table view with less than 5 rows, but the tableview shows like 15+ rows with the rest of the rows as blank(alternative colors for each empty rows). I know there is a style which can be applied to make the remaining empty rows show with white background. However, the height of the table view doesn't reduce to show only the actual number of rows. Is there a way we can restrict the height of the table view to the height of actual rows it has?
Thanks.Hi. Add a listener to your data. Use prefheight to restrict the table height:
table.setPrefHeight(data.size() * 25 + 25);
data.addListener(new ListChangeListener<Person> () {
public void onChanged(ListChangeListener.Change<? extends Person> c) {
table.setPrefHeight(data.size() * 25 + 25);
});It works only when data.size() * 25 + 25 < scene.height -
Suppress number of rows processed message in msql
Is it possible to suppress the feedback message that one gets after running a query.
I've tried the following:
SQL> set feedback off
SQL> set heading off
SQL> @x
3
1 row(s) returned
But still get the message "1 row(s) returned"The Bytes is AVG_ROW_LENGTH * Number of Rows Processed.
For instance you have an EMP table which an AVG_ROW_LENGTH as 37 and the Number of rows processed is 14 then the Bytes will be 518 -
How to Plot number and string in one row (data logger counter via MODBUS) ?
hi all i made data log quantity using Digital Counter via modbus (RS-485) to monitoring quantity and reject that has and Name Operator, Machine and Part Number.
i have problem about plot the number & string in one row, as shown on the picture below :
how to move that string on one row ? i attach my vi.
Thanks~
Solved!
Go to Solution.
Attachments:
MODBUS LIB Counter.vi 39 KBHi rhiesnand,
right now you add 2 new rows to your array.
The solution is to concatenate both row parts to one bigger 1D array before adding that array as new row to your 2D array!
Like this:
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
How to Plot number and string in one row (data logger counter) ?
hi all i made data log quantity using Digital Counter via modbus to monitoring quantity and reject that has and Name Operator, Machine and Part Number.
i have problem about plot the number & string in one row, as shown on the picture below :
how to move that string on one row ? i attach my vi.
Thanks~
Attachments:
MODBUS LIB Counter.vi 39 KBDuplicate and answered - http://forums.ni.com/t5/LabVIEW/How-to-Plot-number-and-string-in-one-row-data-logger-counter-via/m-p...
Maybe you are looking for
-
when i plug in my ipod nano (6th generation) a message on itunes saying the ipod is 'detected but not identified'- i've spent all day trying to fix it and nothing seems to work so i can't sync any songs..
-
What is the CPU usage of X and cpu temp on your Arch?
I just installed the new arch 2009 02. Everything seems to be perfectly out of box, I have lxde DE. But I noticed that in idle X is using around 2~3% cpu compared to below 1% in the old Arch I had before. It seems there is a little lag in the desktop
-
Resetting font on PS CS4 to English - keep showing fonts in Asian font
Can anyone help me?, I keep resetting the font preference to English, but many of the second half of my font list in PS keeps showing in Asian fonts not allowing me to see what the font preview looks like at all. These same fonts are in English in Ai
-
ASUG 2008 Annual Conference, request for info
All, I am very excited about the upcoming ASUG 2008 Annual Conference in Orlando, May 4 - 7, and I hope to see many of you there. For registration info, please visit: http://www.asugannualconference.com/ Meanwhile, we are planning a new session, 'Ho
-
PIDIRUSER - return code 403 Forbidden -
Hi Guys! When I test my scenario with the Directory test tool I get an error: HTTP Connection to ABAP Runtime failed. Error 403: Forbidden.USER: PIDIRUSER. What could be wrong? From which component is made this connection from? in ABAP Part the user