hi i am trying to load about 10K rows for my iphone app. iam getting huge performance problem while retrieving data. i am fetching data column by column by referring sybase tutorials. Like following code i'm trying to load 45 columns of the table.

lrs_resultSet->GetString("acc_alter_code", acc_alter_code, 21);

is this the correct way? please help me out in this. It is taking 5 secs to create an array of 10K.

This question is marked "community wiki".

asked 26 Apr '13, 00:38

Sudha's gravatar image

Sudha
36225
accept rate: 0%

wikified 20 May '13, 03:13

1

That sounds like a lot of data to load into memory at once on a small device... If you are displaying this data, could you load it on demand as the view scrolls (or whatever) instead? Or perhaps load the remainder as a background operation after populating the view?

(26 Apr '13, 13:37) Tim McClements

I'm displaying only 20 rows in a tableview at once. but i have sorting functionality in my app, so on sorting i need to sort whole 10K records in array and i need to display. So i need to load all the records. But can you help me how can i write query for loading on demand?

(28 Apr '13, 23:36) Sudha
Replies hidden
1

Can you let the database do the sorting? It's meant to do that kind of thing :) For performance you'll want to create indexes on the sort columns.

2 ways to load a page at a time: query with 'TOP n START AT m' clause, or keep the cursor open and move the cursor as required. The latter may be faster than TOP/START AT for complex queries. If neither is fast enough, I suppose you'll have to load larger "pages" of rows in the background, say 500 rows at a time. But in any case, if the database is doing the sorting you can get the first page up without delay in the app.

(29 Apr '13, 16:08) Tim McClements

I have 50 columns in the grid. i can sort on any column in 50 columns. So I'm not sorting in query. i will sort the array using NSSortDescriptors (IOS API).

I'm unware of how to load 500 rows at a time. or keep cursor. I checked cursor facility is not available in UltraLite? Or how can use cursors? Can you help me? Thanks a lot for your reply and your support.

(30 Apr '13, 01:25) Sudha
Replies hidden

Do you have any working example project similar to this?

(30 Apr '13, 01:44) Sudha

The TOP n START AT m syntax is used to load blocks of rows. Please see the documentation for the select statement. http://dcx.sybase.com/index.html#sa160/en/uladmin/ul-select-statement.html*d5e29815

By cursor I mean the ULResultSet object. You can retain the object and call the Next/Previous/Relative methods as required to fetch more rows. (Under the covers the result-set object maintains a database cursor for the query...) http://dcx.sybase.com/index.html#sa160/en/ulc/ulc-ulcpp-ulresultset-cla.html*d5e9921

(16 May '13, 12:17) Tim McClements
showing 3 of 6 show all flat view

Hi Sudha,

There is an optimization you can do. GetString() comes in two flavours: one which takes a column id and one which takes a column name (as in your example). The column name one is convenient, but it means UL must look up the column name for each value you fetch. For code which must run quickly/many times, it's faster to use the column id. You can get the column id by using ULResultSetSchema's GetColumnID() function - query it for each column and reuse the ids for all of your Get calls. Or you can just hard-code the column id (they start at 1, matching your query) since you know what the select statement is.

permanent link

answered 26 Apr '13, 13:27

Tim%20McClements's gravatar image

Tim McClements
1.7k1825
accept rate: 34%

Iam using KVC for loading all the columns of the table. So I have created properties in a class for each column. So for matching the column name and property i have used column name flavour of GetString(). I have tried for Column id's also, I have tried to loop through all the columns and took id's and its name and tried load 10K, it was taking 2 secs more than previous method.

(28 Apr '13, 23:43) Sudha
Replies hidden
1

In order for the optimization to work, you must fetch (and save) the column ids only once for all the rows you are fetching...

(29 Apr '13, 15:55) Tim McClements

It would be of great help if you posted the schema (including indexes) of the table(s) involved and the SQL query you are using.

Also please post the version and build number of UltraLite you are using.

Can you check how much free memory the phone has with the database installed? Thanks.

permanent link

answered 26 Apr '13, 10:23

PhilippeBertrand%20_SAP_'s gravatar image

PhilippeBert...
1.4k41733
accept rate: 22%

Schema it contains 55 columns, and i'm not created any index, only primary index is creted by default.

Version number: 12.0.1.3152

I'm unaware of how to check free memory in the phone.

(28 Apr '13, 23:39) Sudha
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×131
×20

question asked: 26 Apr '13, 00:38

question was seen: 929 times

last updated: 20 May '13, 03:13