How do I process a large number of rows using ADO?
I need to iterate through a table with about 12 million records and process each row individually. The project I'm doing cannot be resolved with a simple UPDATE statement.
My concern is that when I perform the initial query that so much data will be returned that I'll simply crash.
Ideally I would get to a row, perform my operation, then go to the next row ... and so on and so on.
I am using ADO / C++
I suggest you simply use the default fast-forward read-only (firehose) cursor to read the data. This will stream data from SQL Server to your application and client memory usage will be limited to the internal API buffers without resorting to paging.
I ran a quick test of this technique using ADO classic and the C# code below and it ran in under 3 minutes (35 seconds without the file processing) on my Surface Pro against a remote SQL Server. I would expect C++ to be a significantly faster
since it won't incur the COM interop penalty. The same test with SqlClient ran in under 10 seconds.
static void test()
var sw = Stopwatch.StartNew();
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff"));
object recordCount;
var adoConnection = new ADODB.Connection();
adoConnection.Open(@"Provider=SQLNCLI11.1;Server=serverName;Database=MarketData;Integrated Security=SSPI");
var outfile = new StreamWriter(@"C:\temp\MarketData.txt");
var adoRs = adoConnection.Execute("SELECT TOP(1200000) Symbol, TradeTimestamp, HighPrice, LowPrice, OpenPrice, ClosePrice, Volume FROM dbo.OneMinuteQuote;", out recordCount);
while(!adoRs.EOF)
outfile.WriteLine("{0},{1},{2},{3},{4},{5},",
(string)adoRs.Fields[0].Value.ToString(),
((DateTime)adoRs.Fields[1].Value).ToString(),
((Decimal)adoRs.Fields[2].Value).ToString(),
((Decimal)adoRs.Fields[3].Value).ToString(),
((Decimal)adoRs.Fields[4].Value).ToString(),
((Decimal)adoRs.Fields[5].Value).ToString());
adoRs.MoveNext();
adoRs.Close();
adoConnection.Close();
outfile.Close();
sw.Stop();
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff"));
Console.WriteLine(DateTime.Now.ToString(sw.Elapsed.ToString()));
Dan Guzman, SQL Server MVP, http://www.dbdelta.com
Similar Messages
-
Processing of large number of records using JDBC Sender Channel
Hi experts,
We have a JDBC-File scenario where in the tables contain about 500K records on an average.
I used multimapping to generate a flat file for every 10K. The problem is ..when I start the JDBC Sender CC, the memory goes up and the J2EE engine restarts. In the Sender CC, I gave the Disconnect from the database option too. The query is SELECT * from TABLE and the Update statement is <TEST>. Please help me out how to solve this.
Regards.Hi
Use the below query,
// Oracle
SELECT Statement : select colname from tblname where rownum<=1000 ;
// MSSQL
select top 1000 colname from tblname
Regards
Ramg -
How can I move a large number of pics from icloud Photos Beta to a PC without having to select each photo?
Hi,
can you please explain why the solution from steve is not the right solution for you.
regards
Peter -
How can I trash a large number of Emails quickly from my iPod touch rather than using the one-at-a-time Edit method?
Once you tap on edit, you can select multiple emails, the tap archive.
-
How to Capture a Table with large number of Rows in Web UI Test?
HI,
Is there any possibility to capture a DOM Tabe with large number of Rows (say more than 100) in Web UI Test?
Or is there any bug?Hi,
You can try following code to capture the table values.
To store the table values in CSV :
*web.table( xpath_of_table ).exportToCSVFile("D:\exporttable.csv", true);*
TO store the table values in a string:
*String tblValues=web.table( xpath_of_table ).exportToCSVString();*
info(tblValues);
Thanks
-POPS -
Af:table Scroll bars not displayed in IE11 for large number of rows
Hi. I'm using JDeveloper 11.1.2.4.0.
The requirements of our application are to display a table potentially displaying very large numbers of rows (sometimes in excess 3 million). While the user does not need to scroll through this many rows, the QBE facility allows drill-down into specific information in the rowset. We moved up to JDeveloper 11.1.2.4.0 primarily so IE11 could be used instead of IE8 to overcome input latency in ADF forms.
However, it seems that IE11 does not enable the vertical or horizontal scroll bars for the af:table component when the table contains greater than (approx) 650,000 rows. This is not the case when the Chrome browser is used. Nor was this the case on IE8 previously (using JDev 11.1.2.1.0).
When the table is filtered using the QBE (to a subset < 650,000 rows), the scroll bars are displayed correctly.
In the code the af:table component is surrounded by an af:panelCollection component which is itself surrounded by an af:panelStretchLayout component.
Does anyone have any suggestions as to how this behaviour can be corrected? Is it purely a browser problem, or might there be a programmatic workaround in ADF?
Thanks for your help.Thanks for your response. That's no longer an option for us though...
Some further investigation into the generated HTML has yielded the following information...
The missing scroll bars appear to be as a consequence of the setting of a style for the horizontal and vertical scroll bars (referenced as vscroller and hscroller in the HTML). The height of the scrollbar appears to be computed by multiplying the estimated number of rows in the iterator on which the table is based by 16 to give a scrollbar size proportional to the amount of data in the table, although it is not obvious why that should be done for the horizontal scroller. If this number is greater than or equal to 10737424 pixels then the scroll bars do not display in IE11.
It would seem better to be setting this height to a sensible limiting number of pixels for a large number of rows?
Alternatively, is it possible to find where this calculation is taking place and override its behaviour?
Thanks. -
Oracle Error 01034 After attempting to delete a large number of rows
I sent the command to delete a large number of rows from a table in an oracle database (Oracle 10G / Solaris). The database files are located at /dbo partition. Before the command the disk space utilization was at 84% and now it is at 100%.
SQL Command I ran:
delete from oss_cell_main where time < '30 jul 2009'
If I try to connect to the database now I get the following error:
ORA-01034: ORACLE not available
df -h returns the following:
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d6 4.9G 5.0M 4.9G 1% /db_arch
/dev/md/dsk/d7 20G 11G 8.1G 59% /db_dump
/dev/md/dsk/d8 42G 42G 0K 100% /dbo
I tried to get the space back by deleting all the data in the table oss_cell_main :
drop table oss_cell_main purge
But no change in df output.
I have tried solving it myself but could not find sufficient directed information. Even pointing me to the right documentation will be higly appreciated. I have already looking at the following:
du -h :
du -h8K ./lost+found
1008M ./system/69333
1008M ./system
10G ./rollback/69333
10G ./rollback
27G ./data/69333
27G ./data
1K ./inx/69333
2K ./inx
3.8G ./tmp/69333
3.8G ./tmp
150M ./redo/69333
150M ./redo
42G .
I think its the rollback folder that has increased in size immensely.
SQL> show parameter undo
NAME TYPE VALUE
undo_management string AUTO
undo_retention integer 10800
undo_tablespace string UNDOTBS1
select * from dba_tablespaces where tablespace_name = 'UNDOTBS1'
TABLESPACE_NAME BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS
MAX_EXTENTS PCT_INCREASE MIN_EXTLEN STATUS CONTENTS LOGGING FOR EXTENT_MAN
ALLOCATIO PLU SEGMEN DEF_TAB_ RETENTION BIG
UNDOTBS1 8192 65536 1
2147483645 65536 ONLINE UNDO LOGGING NO LOCAL
SYSTEM NO MANUAL DISABLED NOGUARANTEE NO
Note: I can reconnect to the database for short periods of time by restarting the database. After some restarts it does connect but for a few minutes only but not long enough to run exp.Check the alert log for errors.
Select file_name, bytes from dba_data_files order by bytes;
Try to shrink some datafiles to get space back. -
JDev: af:table with a large number of rows
Hi
We are developing with JDeveloper 11.1.2.1. We have a VO that returns > 2.000.000 of rows and that we display in a af:table with access mode 'scrollable' (the default) and 'in Batches of' 101. The user can select one row and do CRUD operations in the VO with popups. The application works fine but I read that scroll very large number of rows is not a good idea because can cause OutOfMemory exception if the user uses the scroll bar many times. I have tried with access mode in 'Range Paging' but the application works in strange ways. Sometimes when I select a row to edit, if the selected row is the number 430 in the popup is show it the number 512 and when I want to insert a new row throws this exception:
oracle.jbo.InvalidOperException: JBO-25053: No se puede navegar con filas no enviadas en RangePaging RowSet.
at oracle.jbo.server.QueryCollection.get(QueryCollection.java:2132)
at oracle.jbo.server.QueryCollection.fetchRangeAt(QueryCollection.java:5430)
at oracle.jbo.server.ViewRowSetIteratorImpl.scrollRange(ViewRowSetIteratorImpl.java:1329)
at oracle.jbo.server.ViewRowSetIteratorImpl.setRangeStartWithRefresh(ViewRowSetIteratorImpl.java:2730)
at oracle.jbo.server.ViewRowSetIteratorImpl.setRangeStart(ViewRowSetIteratorImpl.java:2715)
at oracle.jbo.server.ViewRowSetImpl.setRangeStart(ViewRowSetImpl.java:3015)
at oracle.jbo.server.ViewObjectImpl.setRangeStart(ViewObjectImpl.java:10678)
at oracle.adf.model.binding.DCIteratorBinding.setRangeStart(DCIteratorBinding.java:3552)
at oracle.adfinternal.view.faces.model.binding.RowDataManager._bringInToRange(RowDataManager.java:101)
at oracle.adfinternal.view.faces.model.binding.RowDataManager.setRowIndex(RowDataManager.java:55)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.setRowIndex(FacesCtrlHierBinding.java:800)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
<LoopDiagnostic> <dump> [8261] variableIterator variables passivated >>> TrackQueryPerformed def
<LifecycleImpl> <_handleException> ADF_FACES-60098:El ciclo de vida de Faces recibe excepciones no tratadas en la fase RENDER_RESPONSE 6
What is the best way to display this amount of data in a af:table and do CRUD operations?
Thanks
Edited by: 972255 on 05/12/2012 09:51Hi,
honestly, the best way is to provide users with an option to filter the result set displayed in the table to reduce the result set size. No-one will query 2.00.000 rows using the table scrollbar.
So one hint for optimization would be a query form (e.g. af:query)
To answer your question "srollable" vs. "page range", see
http://docs.oracle.com/cd/E21043_01/web.1111/b31974/bcadvvo.htm#ADFFD1179
Pay attention to what is written in the context of +"The range paging access mode is typically used for paging through read-only row sets, and often is used with read-only view objects.".+
Frank -
How can I change the phone number that's used for my iMessages
How can I change the phone number that's used for my iMessages
I Know but i did a number port and the iMessages is showing up using the original number that I had when I first purchased this phone from tmobile
-
How can I delete a large number of messages from my iCloud mailbox in bulk mode?
I decided that I have a large number of e-mail messages in my iCloud mailbox that I do not need anymore and I would like to delete these messages in a single - simple move. How can I do it (Gmail offers a nice way to do this but I cannot find anything similar in iCloud...)?
Archive the contacts you have in Address book, then delete them, they will be removed from iCloud as well. Restore the archive
-
How can I format a large number to have comma separators?
I have numbers that are very large, i.e., in the billions. I want to format the display to show comma separators.
For example:
8000000000 => 8,000,000,000
Is there an easy way to do this?Robert,
There is no way (to my knowledge) to include comma separators in a numeric control or indicator in LabVIEW. If you want commas, you will need to use a string. I have attached an example VI to this post that demonstrates how I would include comma separators in a large number string. There might be an easier way, but this was the first thing that came to mind.
I hope this helps. Good luck with your application, and have a pleasant day.
Sincerely,
Darren N.
NI Applications Engineer
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Attachments:
commas.vi 24 KB -
How do I delete a large number of songs off my iPad
I have a large music collection and have downloaded a large number of songs onto my iPad (10GB). I don't need that much music on my iPad and would like to put the songs back in the cloud. I don't want to have to delete thousands of songs one at a time by swiping. What is the best way to do this?
I have a 4th gen iPad and I have iTunes Match.Then I suspect you do not have iTunes Match enabled. Using that "delete all" command in the Settings does not remove the music from the cloud, nor does it disable iTunes Match. With iTunes Match enabled you will still see all the music.
So go to Settings > iTunes and App Store and make sure iTunes Match is set to ON (green). -
Trouble copying a large number of objects using Acrobat X
Acrobat X is many times slower than Acrobat 9 when copying a large number of objects in a PDF. What used to take one second in Acrobat 9, now takes upwards of 45 seconds or longer in Acrobat X and often causes the application to crash. I am using 10.2.1 on OS X 10.6.8. Has anyone else experienced this performace difference or have any solutions? Any thoughts on the subject would be much appreciated. Thanks.
Since you do not want to crop your images to a square 1:1 aspect ratio changing the canvas to be square will not make your images square they will retain their Aspect Ratio and image size will be changer to fit within your 1020 px square. There will be a border or borders on a side or two borders on opposite sides. You do not need a script because Photoshop ships with a Plug-in script to be used in Actions. What is good about Plugins is the support Actions. When you record the action the plug-in during action recording records the setting you use in its dialog into the actions step. When the Action is played the Plug-in use the recorded setting an bypasses displaying its dialog. So the Action can be Batch. The Action you would record would have two Steps. Step 1 menu File>Automate>Fit Image... in the Fit Image dialog enter 1020 in the width and height fields. Step 2 Canvas size enter 1020 pixels in width and height not relative leave the anchor point centered it you want even borders on two sides set color to white in the canvas size dialog. You can batch the action.
The above script will also work. Its squares the document then re-sizes to 1020x1020 the action re-sizes the image to fit with in an area 1020 x 1020 then add any missing canvas. The script like the action only process one image so it would also need to be batched. Record the script into and action and batch the action. As the author wrote. The script re size canvas did not specify an anchor point so the default center anchor point is uses like the action canvas will be added to two sides. -
hello !
i have an application wich interrogates my Oracle 8i Databse using OCI, my problem is that the number of rows returned is so large ( the totality of rows is 1 million) , how can i have rows returned by packets (as the same way as results returned by a search tool)Use bulk binds (see http://technet.oracle.com/sample_code/tech/pl_sql/htdocs/bulkdemo.txt)
hello !
i have an application wich interrogates my Oracle 8i Databse using OCI, my problem is that the number of rows returned is so large ( the totality of rows is 1 million) , how can i have rows returned by packets (as the same way as results returned by a search tool) -
Hi All,
I have a large number of images that I need to resize the canvas sizes to a square, the images are currently in different sizes. For example, if an image is 1020 x 600 I would like to change the canvas to 1020 x 1020 so that the image becomes a square. I am using CS3 and all the images are jpeg's. I have done research on scripts but the ones I have tried have not worked. Please help.
Thanks.Since you do not want to crop your images to a square 1:1 aspect ratio changing the canvas to be square will not make your images square they will retain their Aspect Ratio and image size will be changer to fit within your 1020 px square. There will be a border or borders on a side or two borders on opposite sides. You do not need a script because Photoshop ships with a Plug-in script to be used in Actions. What is good about Plugins is the support Actions. When you record the action the plug-in during action recording records the setting you use in its dialog into the actions step. When the Action is played the Plug-in use the recorded setting an bypasses displaying its dialog. So the Action can be Batch. The Action you would record would have two Steps. Step 1 menu File>Automate>Fit Image... in the Fit Image dialog enter 1020 in the width and height fields. Step 2 Canvas size enter 1020 pixels in width and height not relative leave the anchor point centered it you want even borders on two sides set color to white in the canvas size dialog. You can batch the action.
The above script will also work. Its squares the document then re-sizes to 1020x1020 the action re-sizes the image to fit with in an area 1020 x 1020 then add any missing canvas. The script like the action only process one image so it would also need to be batched. Record the script into and action and batch the action. As the author wrote. The script re size canvas did not specify an anchor point so the default center anchor point is uses like the action canvas will be added to two sides.
Maybe you are looking for
-
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc 10
I have a script file called xmldr XML_LIB=~/sm/xmlDR/xmldr/lib export XML_LIB CLASSPATH=$CLASSPATH:$XML_LIB/ojdbc14.jar:$XML_LIB/xmldr.jar:$XML_LIB/xml.jar:$XML_LIB/xmlparserv2.jar:$XML_LIB/xsu12.jar; export CLASSPATH java xmlDR $0 $1 $2 $3 $4 $5 $6
-
Podcast Page Graphics: The big ones
Looking for information on providing graphics for the large page which would hold several differrent podcasts... For instance, the White House has a branded page holding al they're 'casts, as does Business Week and Purina. However, the ponly image in
-
How do i export pdf Clip note from premiere pro CC
I can't find anywhere to export as clip note in CC
-
Zsh - lots of blank space upon resizing VTE based terminals
Hello I have an issue that is rendering me sleepless these days. It's about zsh and its behaviour when being run inside a VTE based terminal (e.g. gnome-terminal, xfce4-terminal, roxterm, sakura, ...). When I increase the terminal height, if the buff
-
I've spent 2 hours trying to get this to work. I have a Dell Vostro 400, and it's pretty old, but recently restored. I want to save some of my music that i have on iTunes to my Android Tablet, but in order to, I have to open prefrences. Problem is, E