Performance Issue using min() and max() in one SQL statement
I have a simple query that selects min() and max() from one column in a table in one sql statment.
The table has about 9 Million rows and the selected column has a non unique index. The query takes 10 secs. When i select min() and max() in separate statements, each takes only 10 msecs:
This statement takes 10 secs:
select min(date_key) , max(date_key)
from CAPS_KPIC_BG_Fact_0_A
where date_key != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
This statement takes 10 msecs:
select min(date_key)
from MYTABLE
where date_key != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
union all
select max(date_key) from MYTABLE
Because the first statement is part of an autmatic generated SQL of an application, i can't change it and i have to optimize the data model. How can i speed up the first statement?
I've ran similar query on a table that has 10 milliion rows, with an index on the date column
This is what I have found:
SQL> set timing on
1 SELECT MIN(ID_DATE) MIN_DATE, MAX(ID_DATE) MAX_DATE
2 FROM MY_DATE
3* WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
SQL> /
MIN_DATE MAX_DATE
03-APR-76 06-JAN-02
real: 43383
SQL> SELECT MIN(ID_DATE) MIN_DATE FROM MY_DATE
2 WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
3 UNION ALL
4 SELECT MAX(ID_DATE) MAX_DATE FROM MY_DATE
5 WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
6 /
MIN_DATE
03-APR-76
06-JAN-02
real: 20
SQL> SELECT MIN_DATE, MAX_DATE FROM
2 (SELECT MAX(ID_DATE) MAX_DATE FROM MY_DATE
3 WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD')) ) A,
4 (SELECT MIN(ID_DATE) MIN_DATE FROM MY_DATE
5 WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD')) ) B
6 /
MIN_DATE MAX_DATE
03-APR-76 06-JAN-02
real: 10
SQL> My conculsion, there is nothing you can do to the tables that will improve that particular statement.
Why can't you modify the application?
Similar Messages
-
Performance issue using webelements and crystal
We have 2 reports named, u201CDAMAGE_REPORTSu201D AND u201CTDI_CHARTu201D
DAMAGE_REPORTS
There are 13 dynamic or static Prompts created using Webelements .After clicking on submit button(using
webelement) by selecting the prompt values, TDI_CHART report will get opened below the u201CDAMAGE_REPORTSu201D report.
TDI_CHART
TDI_CHART created using free-hand SQL which contains 2 commands
1. Command-SQL is created based on two categories.
Trend -Trend By Month ,Trend By Quarter,Trend By Week
Non-Trend- Current Month ,Current Year to Date,Last Year to Date,Current Quarter,Last
Quarter,Current Week,Last Week,Last Month,Last Year Total
Charts,Cross-tabs and table information is coming from this Query
2.Image count-contains number of images information based on the prompt selection and it acts as a
URL(opendocument) in the report to open TDI_THUMBNAIL report to display the thumbnail images.
Report information
TDI_CHART Report contains 8 charts,4 cross-tabs, summary information showing in table format(Detail
section) and2 open document links(1.For image count 2.Export to excel(which shows the detail information
of summary table)
Description
If the selection is Non-Trend Value from the Time period parameter , corresponding Chart will be shown along with table information.(Table information is only required for Non-Trend Values).
If the Selection is Trend Value from the Time period parameter,the corresponding cross tab and chart will be shown and others will get suppressed.
Problem Area
After the prompt selection from u201CDamage_Reportsu201D, TDI_CHART report is taking around 1min 30 sec to show the chart and table or cross-tab.
In Database when we execute the above queries, it comes in 12 secs but whereas in reports it takes 1min 30 sec,can you guide us some steps to bring down this time?hello Mufiza,
copy the url created at the step "After the prompt selection from u201CDamage_Reports".
paste this url into a new browser window and press enter.
what is the time to return this report?...this time should also be 1.5 minutes.
it sounds like you are using 2 commands in the same report. this will often cause performance issues, just like linking two stored procedures together or linking two disparate datasources together.
this would not be an issue related to webelements but related to the design of your target report.
jw -
Using Min and MAX function on Bit Field
Hi All,
I am trying to write a SQL Query where i want to aggregate a bit field along with some other numerical fields
I have a Field of type Bit and it can contain data like
Scenario 1: MyBit Field
Row1 Null
Row2 Null
Row3 Null
Scenario 2: MyBit Field
Row1 1
Row2 1
Row3 Null
Scenario 3: MyBit Field
Row1 0
Row2 0
Row3 Null
Scenario 4: MyBit Field
Row1 1
Row2 0
Row3 Null
Scenario 5: MyBit Field
Row1 1
Row2 1
Row3 0
Scenario 6: MyBit Field
Row1 1
Row2 1
Row3 1
Scenario 7: MyBit Field
Row1 0
Row2 0
Row3 0
These are all scenario i can think of, i want to have sql statement which should return me
null if all values are null,
if there is mix of 1, 0 then return NA,
if there is mix of 1,0,null return NA
if there is mix of 1's with Null then return 1 ,
if there is mix of 0's with null return 0 ,
if there is all 0's return 0
if there is all 1's return 1
IS there an elegant way in SQL to handle this
Note : I have other fields in query which are simply getting SUM.Try:
DECLARE @T table (
Scenario int NOT NULL,
col1 int NOT NULL,
col2 bit NULL,
UNIQUE CLUSTERED (Scenario, col2, col1)
INSERT INTO @T
(Scenario, col1, col2)
VALUES
(1, 1, NULL),
(1, 2, NULL),
(1, 3, NULL),
(2, 1, 1),
(2, 2, 1),
(2, 3, NULL),
(3, 1, 0),
(3, 2, 0),
(3, 3, NULL),
(4, 1, 0),
(4, 2, 1),
(4, 3, NULL),
(5, 1, 1),
(5, 2, 1),
(5, 3, 0),
(6, 1, 1),
(6, 2, 1),
(6, 3, 1),
(7, 1, 0),
(7, 2, 0),
(7, 3, 0);
WITH T AS (
SELECT
Scenario,
MIN(col2 * 1) AS min_col2,
MAX(col2 * 1) AS max_col2,
COUNT(*) AS cnt
FROM
@T
GROUP BY
Scenario,
col2
, R AS (
SELECT
Scenario,
MIN(min_col2) AS min_col2,
MAX(max_col2) AS max_col2,
MAX(cnt) AS max_cnt,
SUM(cnt) AS total
FROM
T
GROUP BY
Scenario
SELECT
Scenario,
CASE
WHEN max_cnt = total THEN CAST(min_col2 AS char(1))
WHEN min_col2 = 1 AND max_cnt < total THEN CAST(min_col2 AS char(1))
WHEN max_col2 = 0 AND max_cnt < total THEN CAST(max_col2 AS char(1))
WHEN min_col2 <> max_col2 AND max_cnt < total THEN 'NA'
END AS col3
FROM
R;
GO
AMB
Some guidelines for posting questions...
AYÚDANOS A AYUDARTE, guía básica de consejos para formular preguntas -
Performance issue using WebView and OpenLayers
Hi Team,
i am running javafx 2.2 from jdk7u21.
openlayers version used is 2.12
when i am trying to add a huge number of vectors to a vector layer, the CPU usage goes high and nothing gets displayed.
Most of the CPU usage is done by com.sun.javafx.sg.prism.NGWebView.update()
it works well till around 4K vectors, but goes for a toss beyond that.
OpenLayers Code is as follows.
vector layer Definition
==============
var vector1= new OpenLayers.Layer.Vector("Drivers",{
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
pointRadius: 3,
fillColor : "blue",
graphicName : "circle",
fillOpacity : 1
}, OpenLayers.Feature.Vector.style["default"])),
"select": new OpenLayers.Style({
externalGraphic: "${select_externalGraphic}"
vector1.events.on({
"featureselected": function(e) {
//TODO: on Selection
app.printOnConsole("From Vector Event>>"+e.feature.attributes.name);
app.printOnConsole("From Vector Event"+Object.toJSON(e.feature.attributes));
"featureunselected": function(e) {
//TODO: on Deslect:
Adding the vector code
===============
var mymarker = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(LON,LAT),{
default_externalGraphic: 'triangle_8.png',
select_externalGraphic: 'triangle_8.png',
rat : jsonObj.rat
mylayer.addFeatures([mymarker]);
Please suggest if there is a way i can fine tune my code to display the vectors.If running under a windows make sure you use a 32 bit java runtime (64 bit java runtimes on windows do not have a JavaScript jit compiler and are many times slower).
Try java 8, it has many performance improvements.
https://jdk8.java.net/download.html
Use code tags
https://forums.oracle.com/forums/ann.jspa?annID=1622 -
Performance issue with calendar and applescript
Hi Community,
I have a performance issue using applescript and calendar with this script:
tell application "Calendar"
tell calendar "Cal"
set theList to (get {summary, start date, end date, uid} of events)
end tell
end tell
There are app. 700 events in the calendar "Cal". Therefore the get-command takes about 15 seconds. The problem is, that iCal is completely blocked for this time. This means it is even not possilbe to scroll through the calendar. This problem occurs only under OS X 10.9. With OS X 10.8.x it is still possible to use calendar even a time-consuming get-command is processed.
Any ideas? Maybe there is a way to reduce the task-priority of an applescript?I have to step in here...
1) Must I set "None" or "On Time"
- In order for the Calendar to fire an Alarm, it must know what time to fire the alarm. In the event of an All Day Event, it will go off at 12am. The option for "Repeat", below the "Alarm", states the frequency of the event (Daily, Weekly, Monthly, Yearly, etc). So to set an alarm that fires once a month, set the TIME you want the alarm to go off (Make sure "All Day" is unchecked if you want a specific time), then choose "On Time" for the "Alarm", and one of the several "Monthly" options for "Repeat". If I missed something in what you were asking, please let me know and I will do my best to more directly answer your question.
2) Calendar cannot sync with the Mac.
- Not directly. However, your phone automatically syncs with your Google Calendar, set up if you create your account. If you so choose, you may export your iCal calendar, import it into your Google calendar, and then use your Google calendar (http://calendar.google.com) to manage your agenda. The changes sync automatically with your device.
Once again, I hope this shed some light on things. To the Verizon rep who originally answered this question: I have no intention to bash you, however please bear in mind that your opinions and comments will always be held in higher regard than mine, so if you choose to answer a question, please try to solve the problem as opposed to just answer the question. I have experience with all manner of devices and operating systems, from WebOS to BB to iOS to Android, and I believe this phone has the best hardware coupled with a solid operating system in TouchWiz, and I don't want to see people frustrated with these devices by questions that get nothing more than, "You can't do that" answers from the people that are expected to support them. -
Find more than one min and max in 2D array contain 0 rows
Hi
I have a 2D array and I would like to find the max and min elements between series of 0s. As you can see in the picture If I remove all 0s from the array and use the max and min function then I will have just one min and one max but I need to find min and max after every 0 rows so you can see from the picture ( just as an example) I will have 3 min and 3 max numbers. Would you please help me with this code. Do you now any algorithm that can find min and max between 0s?
I have also attached my code to remove 0s and then search for max and min numbers but as I mentioned I need min and max for every part
Many thanks
Attachments:
2.jpg 82 KB
3.jpg 27 KBThanks altenbach
I have attached the vi to this post. I would really apperciate if you help me with this example. The min values should be 100, 1500 and 4000 and the max values should be 1200,2600,5400 so as u mentioned the output should be this 2D array
100,1200
1500,2600
4000,5400
Attachments:
new.vi 6 KB -
To find out the min and max memory been used by each parameter under SGA_MA
Hi,
Can any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide me
SQL> select name from v$database;
NAME
CRMS65T
SQL> show parameter sga
NAME TYPE VALUE
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 1000M
sga_target big integer 1000MThanks in advanceCan any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide meI guess your question is, each memory components of SGA? if so
SQL> select * from v$sgainfo;
NAME BYTES RES
Fixed SGA Size 2088504 No
Redo Buffers 18882560 No
Buffer Cache Size 616562688 Yes
Shared Pool Size 301989888 Yes
Large Pool Size 4194304 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 947912704 No
Startup overhead in Shared Pool 125829120 No
Free SGA Memory Available 0Also check
SQL> select COMPONENT,CURRENT_SIZE,MIN_SIZE,MAX_SIZE,USER_SPECIFIED_SIZE from v$sga_dynamic_components;
shared pool 301989888 301989888 0 209715200
large pool 4194304 4194304 0 4194304
java pool 4194304 4194304 0 4194304
streams pool 0 0 0 0
DEFAULT buffer cache 616562688 616562688 0 603979776
KEEP buffer cache 0 0 0 0
RECYCLE buffer cache 0 0 0 0
DEFAULT 2K buffer cache 0 0 0 0
DEFAULT 4K buffer cache 0 0 0 0
DEFAULT 8K buffer cache 0 0 0 0
DEFAULT 16K buffer cache 0 0 0 0
DEFAULT 32K buffer cache 0 0 0 0
ASM Buffer Cache 0 0 0 603979776
13 rows selected.
SQL>Edited by: CKPT on Sep 19, 2011 8:55 AM -
OBIEE- Calculating Min and Max Values
Hi Friends,
I have an Issue with regards to calculating Min/Max Values.
In my Data base we dont have Message Count. So we created a Logical column in BMM Layer called "Message Count" based on the column "Out/In No" i.e by creating count of it i.e (Count(out/in no)) in BMM
To calculate Inbound Messages we writing -- filter(Message count using messagetype ='i') at report level
To calculate Outbound Messages we writing -- filter(Message count using messagetype ='o') at report Level
To calculate Total Messages we writing----- "Message Count".
But Now we had an issue to calculate "Min Inbound/Max Inbound/Min Outbound/Max Outbound/Avg In/Avg Out" types of Messages.
To make it clear definition for MIN and MAx is Like This.
Say Ravi received(Inbound) messages 2
Say Roy received(Inbound) messages 5
Say Kiran received(Inbound) messages 11 on a particular date.
So for that particular date Min Inbound is 2
So for that particular date Max Inbound is 11
and Avg Inbound will be (2+5+11)/3
On this basis we have to implement it in OBIEE. For any more clarifications please reply to my thread.
Please reply to my Issue ASAP as it is critical and I am out of time.
Thanks in Advance.
RegardsHi,
Do you mean to ask minimum stock in a plant and maximum stock in a plant over a period of time?
Due to receipts stocks flows in to the storage location of a plant. May be in one period there will be less stock or in one period there will be maximum stock.
May be history tables like MBEWH or MARDH or the report MC.9 ( you need to provide the period as input) etc for your case.If this is not your requirement please reply back.
Regards -
Hello Everyone,
I'm studying QoS and I'm wondering how does a Cisco Engineer find out what the best Minimum and Maximum Threshold rates are when using WRED?
Where would one find these values?
I'm under the impression that it requires a study that's based on the size of the queues, is that correct?
But then, I come to the conclusion that even if the queues are big enough, application critical data like (VOIP) would suffer from delay..
So, how do you calculate the min and max threshold values..
Thanks ahead of time..
PRDisclaimer
The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
Liability Disclaimer
In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
Posting
Setting WRED parameters, for optimal performance, is (IMO) very tedious. Lots of variables involved.
For starters, it shouldn't normally be applied to traffic that's not rate-adaptive, such as VoIP.
It works best for multiple large bulk data transfer TCP streams that are using dropped packets for their principle flow control. Then it can be optimized to maximize their "goodput".
To answer your question, you might study RED literature, and its many variants, found on the Internet.
You also want to study, if you're not already very familiar, with how adaptive flow rate protocols, such as TCP, behave when packets are dropped. (With TCP also be mindful of the different "flavors", i.e. Tahoe, Reno, New-Reno, etc.)
If you have specific questions, post again to this thread, and I might be able to help. -
Difference of value of a dimension based on min and max
Database: Oracle 10g
BO-BOXIr3
Let me explain the exact problem again.
As per the below code, I have the data in this format in my table:
Code:
Date Site ID KWH
1/2/2009 00:00 IN-1 22
1/2/2009 01:00 IN-1 28
1/3/2009 03:00 IN-2 25
1/3/2009 04:00 IN-2 46
1/4/2009 00:00 IN-3 28
1/4/2009 10:00 IN-3 34
1/5/2009 08:00 IN-4 31
1/5/2009 09:00 IN-4 55
1/5/2009 11:00 IN-4 77
1/6/2009 00:00 IN-5 34
Now want to build a report with following columns:
Site Count KWH
IN-1 2 6 (ex.-28-22)
IN-2 2 21
IN-3 2 6
IN-4 3 46 (ex.-77-31)
IN-5 2 34
SITE- distinct site name.
COUNT-count is number of repetitions of site id between min and max date.
KWH -(Delta between the min and max date)
To get the above result I have created 3 report from different queries since not able to get these al in a single report viz Count, Max Value and Min value. Well I have all these 3 reports or table on a single page.
Count-this report will give the count between the dates
Max Value-this report will give me the values of kwh for max dates for each site id
Min Value-this report will give me the values of kwh for min dates for each site id
Now want to create a single report based on these 3 reports which contains the column
Site|Count|KWH
IS IT POSSIBLE?
Or
Is it possible to build such report in a single one with all the required column which I mentioned?
The variables which I created to get the max & min dates,
Mx_dt= =Max([Query 2].[Hourly]) In ([Query 2].[SITE_ID])
Mn_dt= =Min([Query 3 (12)].[Hourly]) In ([Query 3 (12)].[SITE_ID])
For filtering on report used following variables:
if_st_mn=If([mn_dt])=[Hourly] Then "ok" Else "no"
if_st_mx =If([mx_dt])=[Hourly] Then "ok" Else "no"
will filter on "ok" to get the max and min date values.
rest of the variable in the snap are not usable.Yes, you can do it in one report.
I created a sample report from efashion:
Year | Lines | Sales Revenue
2001 | Accessories | $250
2003 | Accessories | $550
2001 | City Skirts | $1050
2003 | City Skirts | $1150...........
Create 2 variables 1) Count and 2) Difference:
1) Count as formula - =Count([Lines]) In Report
2) Difference as formula - =Sum([Sales revenue]) Where (Max([Year]) In Report = [Year]) - Sum([Sales revenue]) Where (Min([Year]) In Report = [Year])
You can replace the formula with your report variables. Then just drag Site ID, Count and Difference variables to your report.
Thanks
Jai -
In my database design and implementation module I'm at the implementation stage. I've set up all of my tables with PK and FK constraints and I'm wondering if you can enforce min and max column constraints. One of the rules of my DB is for my staff table there has to be a minimum of 10 and a maximum of 50, how would I enforce this rule as a constraint on the staff table or isn't this possible?
We have only been learning database design and SQL fundamentals so I don't think I'd be allowed to use triggers or procedures.
Many thanks
Mikemharper wrote:
thanks guys these commands were accepted
alter table staff
add constraint chk_staff_max check (staff_id <= 50);
alter table staff
add constraint chk_staff_min check (staff_id >= 10);
Thing is my staff_id's are in the format 'S110001' will these constraints only check for integers 10 - 50? maybe I need to use a count function on the column or something?
thanks again for your help!
MikeCheck constraint can also be used to check a list of values.
example:
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name> LIKE <condition>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name> NOT LIKE <condition>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name>
IN (<comma delimited list of values>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name>
NOT IN (<comma delimited list of values>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name> BETWEEN <lower_value>
AND <higher_value>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name>
NOT BETWEEN <lower_value> AND <higher_value>);
ALTER TABLE <table_name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name>) > (<condition>); -
Global Change or filter based on Min and Max dates
Hi Guys,
Hopefully there is a genius out there that is an expert with filters and or global changes, I am after a solution and can’t work out if it is possible to do in P6.
Based on a filter (using codes to select a group of activities) I want to write a value into two date UDF Fields can I:
Run a global change to give the earliest and latest date in the group and write the result to all tasks in the group? or
Is there a mindate maxdate option in Global change or filter? Or
If these tasks were grouped in the activity view can a global change be written to fill down the dates that the summary level is displaying, which are essentially the min and max dates of the groups.
I could do this pretty easily in excel but I have over a 100 projects and doing the import one at a time is not feasible.
I could create LOE’s but as my variables are constantly changing and due to the volume also not an option.
Summary bars are not an option eithers as I am writing the UDF’s to get all the bars I want on one line,
An option for me might be to do it using Legare but I would prefer to see if I can get it done in P6 first.
Cheers
RobYes, you can do it in one report.
I created a sample report from efashion:
Year | Lines | Sales Revenue
2001 | Accessories | $250
2003 | Accessories | $550
2001 | City Skirts | $1050
2003 | City Skirts | $1150...........
Create 2 variables 1) Count and 2) Difference:
1) Count as formula - =Count([Lines]) In Report
2) Difference as formula - =Sum([Sales revenue]) Where (Max([Year]) In Report = [Year]) - Sum([Sales revenue]) Where (Min([Year]) In Report = [Year])
You can replace the formula with your report variables. Then just drag Site ID, Count and Difference variables to your report.
Thanks
Jai -
Hi,
I need to perform a calculation:
(max(min(C,2.375),0)+max(min(Y,2.375),0))/6
if the value of c is less than 2.375 then it has to accept the value of C else 2.375.
on it i need to perform the max operation.
How can i do this?Hi,
MIN and MAX, like all the aggrgate functions, take only one argument.
Perhaps you're thinking of the row functions LEAST and GREATEST, which can take one or more arguments.
For example:
GREATEST ( LEAST ( c
, 2.375
, 0
)will return
2.375 if c is greater than 2.375,
0 if c is less than 0, or
c otherwise.
CAUTION: Unlike the aggregate functions, that ignore NULLs, GREATEST and LEAST will return NULL if any of their arguments are NULL. -
hello,
i need to know the min and max for my signal but only on parts that i want to define by a trigger. The question is to know how i could(in my while loop) only analyse a aprt of my signal but not the whole one. i can't use a for loop because i need to see my signal all the time.
thanksGuillaume Trager,
For the triggering part of your application, there are several tutorials and example programs available to you at NI Developer Zone >> Development Library >> Measurement Hardware >> Analog Input/Output >> Analog Input >> Triggering.
Once you have the proper triggering program, you can use the Waveform Min Max.vi or Waveform Peak detection.vi to analyze your peak data. The Trigger and Gate Express VI may also work as a software trigger.
Good luck with your application. -
Help with Video Performance Issues using Flash
Asking on behalf of a customer who has been unable to get any answers so far - are you able to help?
Background:
We have a port of our Game Development Kit which allows us to recompile all our games using Crossbridge (http://adobe-flash.github.io/crossbridge/) into SWF without any code modifications.
Overview:
Our framework is using OpenGL for rendering and we have successfully ported it along with the audio and video to run in Flash.
We are experiencing performance issues using Video. We cannot use image sequence as some of the video animations are too long and would increase the download to an unacceptable size. Assets vary between 256x256 - 1024x1024 videos.Here's the rest of the story. Let me know if you can see any resolution, and I will connect him to the forums. Thank you.
Current Video Solution:
We create an instance of NetConnection, NetStream, and Video according to most samples out there, and invoke draw to rasterize the Video DisplayObject into a BitmapData instance.
The BitmapData instance has a fixed color component layout which is not compatible with Stage3D texture and is therefore has to be reformatted before uploaded to Stage3D Texture (See Code Listing below).
Our Problems:
Performance issues with RGBA conversion (either using copyChannel or manually reformatting is not fast enough) natively in as3; this required for stage3d texture.Copying each channel individual using bitmapdata.Copychannel seems faster, but not significantly faster.
Cannot detect when video frame has been updated, therefore we may copy pixels that are not needed in enterframe (processpixel).
Looping video, our current solution uses the NET_STATUS event Buffer empty; Is there a better way to loop videos than checking buffer and seeking to 0.
Stepping video, loading FLV or MP4 side by side assets from HTTP or embedded does not support stepping? Is there another way?
ActionScript Code Listing:
video_nc = new NetConnection();
video_nc.addEventListener(NetStatusEvent.NET_STATUS , onConnect);
video_nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR , trace);
video_nc.connect(null);
// OnConnect Event:
this.ns = new NetStream(e.target as NetConnection);
eventclient = new Object();
eventclient.onMetaData = onMetaData;
this.ns.client = eventclient;
ns.play(flvfile);
ns.pause();
//onMetaData event:
this.width = infoObject.width;
this.height = infoObject.height;
this.textureWidth = NextPowerOfTwo(this.width);
this.textureHeight = NextPowerOfTwo(this.height);
cliprect = new Rectangle(0, 0, this.width ,this.height);
cliprect.x = 0;
cliprect.y = 0;
cliprect.width = this.textureWidth;
cliprect.height = this.textureHeight;
totalFrames = infoObject.duration * infoObject.fps;
this.hasAlpha = true;
if(infoObject.videocodecid == 5)
this.hasAlpha = true;
this.bitmapData = new BitmapData(this.textureWidth, this.textureHeight, hasAlpha, 0xff000000);
this.video = new Video(this.width, this.height);
this.video.attachNetStream(ns);
this.video.addEventListener(Event.ENTER_FRAME, processPixels);
// processPixel method:
BitmapData.draw(video);
GLAPI.instance.glBindTexture(GLAPI.GL_TEXTURE_2D,this.textureId);
var fmt:uint = GLAPI.GL_ARGB;
// converting pixels using copychannel or loop through pixels
GLAPI.instance.glBindTexture(GLAPI.GL_TEXTURE_2D,this.textureId);
GLAPI.instance.glTexImage2D(GLAPI.GL_TEXTURE_2D, 0, fmt, this.textureWidth, this.textureHeight, 0,fmt, GLAPI.GL_UNSIGNED_BYTE, 0, convBitmapData.getPixels(cliprect));
Maybe you are looking for
-
This started yesterday and progressively became worse. It started when I added a password to my device. I've had the phone for 2 years and never used a password, but recent events persuaded me to do so. I'm not sure if this is just a coincidence, or
-
UI Not appearing in GP Application
I created two COs and while testing, the UI is not appearing. I have followed the document for integrating two webdynpro applications. what and where could be the possible error. The build and all is fine.
-
Does entourage 2008 solve all the new 10.6.3 ical syncing issues?
I am keeping a running list of known issues with entourage and ical after the 'upgrade' from 10.4 to 10.6.3 OS. I have had two duplicated entourage ical calendars, time shift of events and now lastly, when i went to sync at 11pm last night, entourage
-
I've lost my headings -- file, edit, bookmarks, tools. How can I get them back?
-
Trying to download adobe reader XI, it is asking for a default application to run
I am trying to install adobe reader XI on a fresh copy of windows 7 32 bit, it downloads but i do not have an option to run, just to save or open