Performance issue and indexing doesn't help
I created a view the SQL is basically simple but I need to group data based on a value returned from a function. I think this is slowing the performance. I first added a regular index on this, then added a function based index but neither helps. I get the data I need, but it takes too long. I hope someone can give me some ideas about how to optimize the performance of my SQL.
The base table has 1318408 rows. I need to select only a few columns and group and count the rows based on a date value in one of the columns. However the date in the table contains only an end of week value and I need to report based on quarters. The report needs both a date value and a text value for the quarter. So I created two functions that accept a date value and return a date value for the quarter start date and a text value for the quarter the date falls within respectively; my SQL is like this:
select
GLC_DATE2CAL_QRT_STARTDATE_FN(s.work_week_end_date) cyquarter_start_date,
GLC_DATE2CAL_QRTYR_FN(s.work_week_end_date) cyquarter_text,
s.ethnicity ethnicity_code,
et.description ethnicity_desc,
count( unique employee_id ) number_employees
from cpr_employees_snapshot s, ct_vendor_ethnicities et
and trim(s.ethnicity) = et.ethnicity_id
group by GLC_DATE2CAL_QRT_STARTDATE_FN(s.work_week_end_date), GLC_DATE2CAL_QRTYR_FN(s.work_week_end_date), s.ethnicity, et.description
this takes about 1 1/2 minutes to retrieve the data
when I do not use the functions and run this SQL:
select
s.work_week_end_date,
s.ethnicity ethnicity_code,
et.description ethnicity_desc,
count( unique employee_id ) number_employees
from cpr_employees_snapshot s, ct_vendor_ethnicities et
and trim(s.ethnicity) = et.ethnicity_id
group by s.work_week_end_date, s.ethnicity, et.description
it takes 7 seconds.
Well I was successful in writing a case statement that works as a select and it reduces the retrieval time to 5 seconds, the problem now is that when I create a view with it the view is created but with compilation errors; if the select work without errors I don;t know why that is happening. Here is the create view SQL:
CREATE OR REPLACE FORCE VIEW GLC_WORKER_ETHNICITY_VW
cyquarter_start_date,
cyquarter_text,
cyquarter_end_date,
ethnicity_code,
ethnicity_desc,
number_employees
AS
select
case to_number(to_char(s.work_week_end_date, 'mm'))
when 1 then to_date('1/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 2 then to_date('1/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 3 then to_date('1/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 4 then to_date('4/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 5 then to_date('4/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 6 then to_date('4/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 7 then to_date('7/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 8 then to_date('7/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 9 then to_date('7/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 10 then to_date('10/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 11 then to_date('10/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
when 12 then to_date('10/1/' || to_char(s.work_week_end_date, 'yyyy'),'mm/dd/yyyy')
end cyquarter_start_date,
'Q' || to_char(s.work_week_end_date, 'Q') || ' CY ' || to_char(s.work_week_end_date, 'yyyy') cyquarter_text,
s.ethnicity ethnicity_code,
et.description ethnicity_desc,
count( unique employee_id ) number_employees
from cpr_employees_snapshot s, ct_vendor_ethnicities et
where package_id = 727260
and trim(s.ethnicity) = et.ethnicity_id
group by s.work_week_end_date, s.ethnicity, et.description
Similar Messages
-
ABAP performance issues and improvements
Hi All,
Pl. give me the ABAP performance issue and improvement points.
Regards,
HemaPerformance tuning for Data Selection Statement
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of
entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the
length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Nested selects
The plus:
Small amount of data
Mixing processing and reading of data
Easy to code - and understand
The minus:
Large amount of data
when mixed processing isnt needed
Performance killer no. 1
Select using JOINS
The plus
Very large amount of data
Similar to Nested selects - when the accesses are planned by the programmer
In some cases the fastest
Not so memory critical
The minus
Very difficult to program/understand
Mixing processing and reading of data not possible
Use the selection criteria
SELECT * FROM SBOOK.
CHECK: SBOOK-CARRID = 'LH' AND
SBOOK-CONNID = '0400'.
ENDSELECT.
SELECT * FROM SBOOK
WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.
Use the aggregated functions
C4A = '000'.
SELECT * FROM T100
WHERE SPRSL = 'D' AND
ARBGB = '00'.
CHECK: T100-MSGNR > C4A.
C4A = T100-MSGNR.
ENDSELECT.
SELECT MAX( MSGNR ) FROM T100 INTO C4A
WHERE SPRSL = 'D' AND
ARBGB = '00'.
Select with view
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T
WHERE DOMNAME = DD01L-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
SELECT * FROM DD01V
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
Select with index support
SELECT * FROM T100
WHERE ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
SELECT * FROM T002.
SELECT * FROM T100
WHERE SPRSL = T002-SPRAS
AND ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
ENDSELECT.
Select Into table
REFRESH X006.
SELECT * FROM T006 INTO X006.
APPEND X006.
ENDSELECT
SELECT * FROM T006 INTO TABLE X006.
Select with selection list
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
SELECT DOMNAME FROM DD01L
INTO DD01L-DOMNAME
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
Key access to multiple lines
LOOP AT TAB.
CHECK TAB-K = KVAL.
ENDLOOP.
LOOP AT TAB WHERE K = KVAL.
ENDLOOP.
Copying internal tables
REFRESH TAB_DEST.
LOOP AT TAB_SRC INTO TAB_DEST.
APPEND TAB_DEST.
ENDLOOP.
TAB_DEST[] = TAB_SRC[].
Modifying a set of lines
LOOP AT TAB.
IF TAB-FLAG IS INITIAL.
TAB-FLAG = 'X'.
ENDIF.
MODIFY TAB.
ENDLOOP.
TAB-FLAG = 'X'.
MODIFY TAB TRANSPORTING FLAG
WHERE FLAG IS INITIAL.
Deleting a sequence of lines
DO 101 TIMES.
DELETE TAB_DEST INDEX 450.
ENDDO.
DELETE TAB_DEST FROM 450 TO 550.
Linear search vs. binary
READ TABLE TAB WITH KEY K = 'X'.
READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
Comparison of internal tables
DESCRIBE TABLE: TAB1 LINES L1,
TAB2 LINES L2.
IF L1 <> L2.
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = SPACE.
LOOP AT TAB1.
READ TABLE TAB2 INDEX SY-TABIX.
IF TAB1 <> TAB2.
TAB_DIFFERENT = 'X'. EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF TAB_DIFFERENT = SPACE.
ENDIF.
IF TAB1[] = TAB2[].
ENDIF.
Modify selected components
LOOP AT TAB.
TAB-DATE = SY-DATUM.
MODIFY TAB.
ENDLOOP.
WA-DATE = SY-DATUM.
LOOP AT TAB.
MODIFY TAB FROM WA TRANSPORTING DATE.
ENDLOOP.
Appending two internal tables
LOOP AT TAB_SRC.
APPEND TAB_SRC TO TAB_DEST.
ENDLOOP
APPEND LINES OF TAB_SRC TO TAB_DEST.
Deleting a set of lines
LOOP AT TAB_DEST WHERE K = KVAL.
DELETE TAB_DEST.
ENDLOOP
DELETE TAB_DEST WHERE K = KVAL.
Tools available in SAP to pin-point a performance problem
The runtime analysis (SE30)
SQL Trace (ST05)
Tips and Tricks tool
The performance database
Optimizing the load of the database
Using table buffering
Using buffered tables improves the performance considerably. Note that in some cases a stament can not be used with a buffered table, so when using these staments the buffer will be bypassed. These staments are:
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clasuse that contains a subquery or IS NULL expression
JOIN s
A SELECT... FOR UPDATE
If you wnat to explicitly bypass the bufer, use the BYPASS BUFFER addition to the SELECT clause.
Use the ABAP SORT Clause Instead of ORDER BY
The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The datbase server will usually be the bottleneck, so sometimes it is better to move thje sort from the datsbase server to the application server.
If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT stament to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the datbase server sort it.
Avoid ther SELECT DISTINCT Statement
As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplciate rows. -
I changed my Apple ID at the Apple website but it won't let me change it on my iPhone 5 (gMail, iCloud) and syncing doesn't help.
On your iPhone...
Close All Open Apps... Sign Out of your Account... Perform a Reset... Try again...
Reset ( No Data will be Lost )
Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
http://support.apple.com/kb/ht1430 -
Why does my safari browser frequently gives me a gray screen? I resetted my safari many times and it doesn't help. Also sometimes when I scroll it gives me this weird scrolling effect where everything is either upside or messed up.
This article is for startup but it might help. http://support.apple.com/kb/ts2570
-
Adobe Acrobat 9 complains that licensing no longer works and repair doesn't help? Ideas?
Adobe Acrobat 9 complains that licensing no longer works and repair doesn't help. Ideas?
Problem ocurred on Windows XP, Acrobat 9 Standard. Believe error was 138:4 - licensing error
Solution using Windows XP, Administrative tools under Control Panel
Control Panel – Select
Administrative Tools – Double Click
Services – Double Click
FLEXnet Licensing Service (Right click and select Properties)
General Tab: Startup Type – change “Disabled” -> “Automatic” Press Apply.
Recovery Tab: 1st, 2nd, and Subsequent Failures – change “Take No Action” -> “Restart the Service” Press Apply
General Tab: Service Status – press “Start Button” Press Apply
Services window – check FLEXnet Licensing status = “Started”
Verify fix by starting Adobe Acrobat 9 (rebooting not required). -
Fire fox loads some websites and not others. Clearing cache and history doesn't help.
Fire fox loads some websites and not others. Pages that don't load in Firefox do load in other browsers. Clearing cache and history doesn't help.
One of the websites that doesn't load is google.com! It loads some of the page, just some menu items at the top of the page. Then, it hangs and remains in the Loading state (with the spinning wheel and "Loading" in the tab) indefinitely.
The problem started after 3.6.11 was installed. I'm on Mac OS 10.6.4.
I would be happy if you just showed me where I can download 3.6.10. Also, is there anything special I have to do if installing an older version?I ended up going into the clear history settings and setting it to clear history when Firefox closes and chosing it to clear history and cooking and browsing history when Firefox closes. Now the links work fine and the last page I was looking at before I closed Firefox is no longer there when it opens again. Problem solved!
-
i would like to restore my iphone to ios 4.3.5 from 5.0.1. i've tried and watched videos over youtube and it doesn't helps. is there any other specific way? the ios 5.0.1 makes my phone crash and drains my battery whenever i tried to switch it back on. kindly help me.
There is no legit way to do this at all.
-
My system preferences won't load. It opens straight up to the desktop folder and pictures won't load, leaving me with a color wheel. I've tried restarting my computer and that doesn't help. System preferences just won't open/load at all. Any ideas?
Deleting the System Preference or other .plist file
..Step by Step to fix your Mac -
Can't open soundcloud app in iPhone 4s(restart and uninstal doesn't help)
can't open soundcloud app in iPhone 4s(restart and reinstal doesn't help)
The update didn't apply correctly.
Did you follow the steps exactly in order to restore? disconnect all cables, open iTunes, then connect micro usb
Apple TV (2nd and 3rd generation): Restoring your Apple TV
Make sure to connect directly to computer, not a keyboard port or USB hub. Try a different cable. -
My G4 sometimes loses contact with softbank network, and reset doesn't help. I just wait. What is wrong?
g4 sounds like a mac rather then an iphone is this in the correct forum?
-
Some of my Apps don't connect to the internet. For example, NY Times Web App, says it can't connect. But when I access it from Safari it does (it is a web site and the App just accesses it form the desktop of the IPAD). I have a number of Apps like this. I've removed and reinstalled and it doesn't help. Please help!
Thank you.On the wireless networks that your Mac has had trouble connecting to, do you know which Wireless Security type (WEP, WPA, or WPA2) is being used?
If it is WEP, one of the problems is that the actual standard relies on a 10 character HEX key for 40bit WEP and a 26 character HEX key for 128bit WEP. In order to make things easier, vendors use certain algorithms to convert simple alphanumeric passwords (or passphrases) into HEX keys, thus enabling the use of simple easy to remember WEP password rather than lengthy HEX keys. The problem is that different vendors use different algorithms to generate the HEX key and therefore a ASCII password on an AEBS will be hashed differently on a non-Apple client and vice versa. You may find the following Apple Support article helpful. -
Can receive mail, but it takes a little while. Try and send a email but it never sends, bottom left corner says sending 1 of 1 but never sends. I've shut down and restarted iPad but that doesn't help. What to do to correct this and what is the cause?
In that case your email provider's server is having difficulties to deliver the message to the recipients email provider server.
This has got nothing to do with Thunderbird.
There is little you can do though. You may have the recipient to check with his email provider if they have any issues. -
Performance issue and data getting interchanged in BO Webi report + SAP BW
Hi,
We are using SAP BW queries as the source for creating some BO reports.
Environments :
SAP - SAP BI 7.1
BO - BO XI 3.1
Issues :
The reports were working fine in Dev and Q with less data. But when we point the universes to BW prod ( where we have much data), the reports are taking quite a long time to refresh and getting timed out. This query has some key figures which are having customer exits defined to show only one month data. And also BW accelerators are updated for the infocubes pertaining to this query. The BO report is giving data if we apply a filter in 'Query Panel' of Webi to show only current month dates. But then the issue is the values are getting interchanged for many objects. For ex: there are 2 objects- ABS version and Market region. The values are getting interchanged in the BO level.
Please let us know if anything needs to be done in BO or BW to fix this issue if anyone has faced the same
Also Please let us know if customer exits and accelerators works fine with BO
Thanks
SivakamiHi,
Thanks Roberto. We'll check the notes
@Ingo,
We are able to solve the performance issue by removing unused Key figures and dimensions from the query, but the column value interchange issue still persisits
The build version is - 12.3.0
Query Stripping
Where should we enable query stripping? When i went through some documentation it was written that it'll be enabled automatically from XI 3.1 Sp3. Can you please let us know if its so and what we need to do to enable it.
The coulmn interchange is happening when we use dimensions in a certain order. When product type is used along with Market region. Market region shows values of Product type also in Webi report.
Thanks & Regards,
Sivakami -
When applications stop responding and restarting doesn't help
I've trying to get into Photoshop, but while it's loading, it stops responding. I then have to force quit it. I tried to get into it many more times, but it still didn't work. I tried restarting the computer and that didn't help either. What do I do?
Did you install PS from the install disks or migrate it over from another Mac using the Migration Assitant?
If you migrated it over, try uninstalling in and reinstalling from the install disks. Some users have reported issues when they migrated PPC-coded apps over to an Intel Mac. -
<blockquote>Locking duplicate thread.<br>
Please continue here: [[/questions/880054]]</blockquote>
Question
Every time I try to open Firefox I get a popup saying it is already open, and to close it or restart; but it is NOT open, and restarting doesn't heDuplicate Thread LOCK please
* Continue here - https://support.mozilla.com/en-US/questions/880054
Maybe you are looking for
-
Confirm performance of Service/Goods Receipt
We are using SRM 4.0 SRM Server 5.0 in extended classic scenario. Our backend is a R/3 system version 4.70. When changing a purchase order via transaction BBP_POC on the header data tab, go to the follow-on documents. At the top of this screen is
-
WHY have my iDVDs stopped playing correctly?
I would appreciate any help very much. I have used the same Mac, media, and DVD player for at least a year. When I make a DVD, I check it on a PS3 and a DVD player seperately to ensure they work. I'm a wedding photographer, and provide simple video s
-
Subtitle problems CS5 encore 5
Hi Does someone have an explanation for me on a subtitle issue I seem to have wtih CS5/ Encore 5 inbuilding a DVD. I have a single timeline, 4 chapters, each in a different chapter playlist. 16:9 format, 2 audio tracks, 2 subtitles tracks. When the D
-
Gift email hasn't arrived...it's been 4 days.
My brother bought me two CDs (or rather a 2-cd set and a cd- compilation set) and he gifted them to me. The one's e-mail (NOW 62) came through, however the second (AC/DC Collection) hasn't come through. The email address has been changed twice and
-
I get a few random characters on a few webpages, slow webpage downloads and a few webpages incorrectly formatted.