Results 1 to 17 of 17

Thread: reduce data retrieval time

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    reduce data retrieval time

    is there any way to reduce time required to retrrive whole data from database and adding it to listview control.
    i am having records about 3500 from 1 tables and for for each record it search for record in 2nd table and depending on 4to 5 conditons, i have to make color of each record dispalyed in list view control as diffrent color.
    my database is in access and located on server.
    it takes much time.
    can you help me to reduce time ?
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: reduce data retrieval time

    Try hiding the Listview when you are loading it, that should speed up things a bit. Then make it visible after it is loaded.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reduce data retrieval time

    Reducing the number of records loaded would help significantly.

    Is it necessary to load all 3,500 records at once? Can these records be divided into categories and only those records meeting the category criteria get loaded?

  4. #4
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

    Re: reduce data retrieval time

    A slow network can slow you down too.

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: reduce data retrieval time

    Its probably the multiple iterations and per record test that's slowing you down.

    What are the conditions? The tables structures?

    Maybe we can create a joined table (left join, where tabel1 is lefthand side) and in addition to the fields shown in the listview we can add other fields for each condition (checked against table2) and these fields will be used to format the listview output. That way you need to iterate through the recordset only once for adding the listitem and formatting it.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    yes.
    no of conditions per record is about 4 to 5.
    and i can not use any join condition as i have to look up a whole table record in another table.
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: reduce data retrieval time

    what's the table structure?
    post your current code

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    my code is so long.
    VB Code:
    1. rs.Open strsql, conn_proc.con, 3, 3
    2. While rs.EOF = False
    3.     Set t1 = listv1.ListItems.Add(Text:=rs!proj)
    4.     i = 0
    5.     ReDim cnt(rs.Fields.Count - 7) As Long
    6.    
    7.    
    8.     For Each J In cnt
    9.         i = i + 1
    10.         If rs.Fields(i).Type = adDate Then
    11.             t1.SubItems(i) = Trim(" " & Format(rs.Fields(i).Value, "dd-mmm-yyyy") & " ")
    12.         Else
    13.             t1.SubItems(i) = Trim(" " & rs.Fields(i).Value & " ")
    14.         End If
    15.         If i = 9 Then
    16.             'If Val(Trim(" " & rs!cflag & " ")) = 0 Then
    17.              t1.ListSubItems(9).ForeColor = RGB(255, 0, 0)
    18.             'If Val(Trim(" " & rs!bal & " ")) = 0 Then t1.ListSubItems(9).ForeColor = &H8000&
    19.             If Val(Trim(" " & rs!rqty & " ")) > Val(Trim(" " & rs!bal & " ")) And Val(Trim(" " & rs!bal & " ")) > 0 Then t1.ListSubItems(9).ForeColor = RGB(0, 0, 255)
    20.         End If
    21.     Next
    22.  '   If Val(Trim(" " & rs!cflag & " ")) = 0 Then t1.Selected = False
    23. '    If Val(Trim(" " & rs!cflag & " ")) = 1 Then
    24. '        t1.Checked = True
    25. '    End If
    26.     schno = ""
    27.     If rs!reci = "" Then
    28.         t1.ListSubItems(1).ForeColor = RGB(255, 0, 250)
    29.     End If
    30.        
    31.     act1 = ""
    32.     remdate = ""
    33.     '*************************8
    34.    
    35.     srno = rs!srno
    36.     rno = rs!rno
    37.     rs1.Open "select * from follow_up where srno = " & srno & " and rno = '" & rno & "' order by id desc", conn_proc.con, 3, 3
    38.     If rs1.RecordCount > 0 Then
    39.         If rs1!ddate <> "" Then r1 = Format(rs1!ddate, "dd-mmm-yyyy")
    40.         If rs1!remdate <> "" Then remdate = Format(rs1!remdate, "dd-mmm-yyyy")
    41.         If rs1!act <> "" Then act1 = Trim(" " & rs1!act)
    42.         If rs1!schno <> "" Then schno = Trim(" " & rs1!schno)
    43.         If rs1!pname <> "" Then pname = Trim(" " & rs1!pname)
    44.         t1.SubItems(15) = pname
    45.         actprev = ""
    46.  
    47.             rs1.MoveNext
    48.                    If rs1.EOF = False Then
    49.                     actprev = Trim(" " & rs1!act)
    50.                     rs1.MovePrevious
    51.                 End If
    52.         If actprev = "" Then actprev = act1
    53.     End If
    54.       'If LCase(Trim(act1)) = "sch" Or LCase(Trim(act1)) = "po" Then
    55.         colchange = ""
    56.        
    57.        
    58.         If schno <> "" Then
    59.             If ((LCase(actprev) <> "enquiry") Or (LCase(act1) = "sch" Or LCase(act1) = "po")) Then
    60.                 colchange = &H8000&
    61.             End If
    62.         End If
    63.        
    64.      
    65.         If Val(Trim(" " & rs!EMER)) = 1 Or Val(Trim(" " & rs!pref)) = 1 Then
    66.                colchange = &HFAAF4
    67.         End If
    68.    
    69.    
    70.          
    71.     If Val(Trim(" " & rs!rtype)) = 1 Then
    72.         colchange = &H8582F0
    73.     End If
    74.    
    75.              
    76.     If Val(Trim(" " & rs!descr)) = 1 Then
    77.         colchange = &HC0C000
    78.     End If
    79.    
    80.     If colchange <> "" Then
    81.         For ij = 1 To t1.ListSubItems.Count
    82.             t1.ListSubItems(ij).ForeColor = colchange
    83.         Next
    84.         t1.ForeColor = colchange
    85.     End If
    86.    
    87.     rs1.Close
    88.    
    89.     '**************************8
    90.            
    91. '    r1 = get_last_rcd(rs!rno, rs!srno)
    92.     If r1 <> "" Then t1.SubItems(14) = r1
    93.        t1.SubItems(13) = schno
    94.            
    95.     If LCase(frmlogin.cat) = "power user" Or LCase(frmlogin.cat) = LCase("administrator") Or LCase(frmlogin.cat) = LCase("purchase department") Then
    96.         t1.SubItems(12) = act1
    97.     Else
    98.         t1.SubItems(12) = ""
    99.     End If
    100.     If remdate <> "" Then t1.SubItems(10) = Format(rs!ddate, "dd-mmm-yyyy")
    101.     rs.MoveNext
    102. Wend
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: reduce data retrieval time

    what's the sql on line 1?

    rs.Open strsql, conn_proc.con, 3, 3

  10. #10
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: reduce data retrieval time

    And the table structures (field names, data types) pls.

  11. #11
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: reduce data retrieval time

    shukla, have you tried GetRows yet?

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    i have not tried GetRows method.
    can you tell me about it.

    VB Code:
    1. strsql = "select proj,req.rno,req.dt,item,req_details.size1,reason,rqty,req_details.unit1,bal,edate,ddate,srno,cflag,reci,emer,rtype,descr,pref from req,req_details where req.rno  = req_details.rno and bal > 0 and sanc <> '' and val(canreq) <> 1 "
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  13. #13
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: reduce data retrieval time

    first i need you to identify each field with table name first .. eg. like you have with a couple of them... table.FieldName.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    req is first table then req_details is sencond and third is follow_up
    for each record in req.thre is 1 or more records and for each record in req_details there i s or not record in follow_up
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  15. #15
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: reduce data retrieval time

    Is this an access database? If so, could you please zip up and post the database

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    i can not because my organisation will not allow for it.
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: reduce data retrieval time

    please tell me if anyone can suggest me.
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width