Results 1 to 7 of 7

Thread: Creating Index (problem ??)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Creating Index (problem ??)

    I am using vb6 to create an index for a dbaseIII table

    The table name is 'MVDETAIL.DBF'
    Size is 8.34 MB

    It is a non-unique index and has been running for about 2.5 hours now.
    This seems a little long to me, is it that I'm just impatient or should I kill the execution and check the code?

    The SQL statment in code is

    Code:
    1. SQLst = "CREATE INDEX xdetic ON mvdetail (det_icode)
    2. CN.execute sqlst

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

    Re: Creating Index (problem ??)

    2.5 hours does sound a little excessive to me.

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Creating Index (problem ??)

    It depends how the index is created.. if it is effectively a Clustered index (items re-arranged on disk), then it could take a while to move things around.

    Saying that, unless the sorting is particularly badly designed (say a Bubble Sort, directly on disk rather than in memory) it shouldn't take as long as that for an 8 MB file.


    I would recommend checking if any other processes are working with the same file, as you may actually be waiting for a lock to clear.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Re: Creating Index (problem ??)

    There are no other programs or processes accessing the file

    while the application is running (in debug) I can open the folder containing the files (both .dbf and .ndx) the new index is there and almost immediately shows 2.54 MB of data (no I can't open the file as it is being used by the VB app) it will show the same thing after 1 hr, or 2, or 3...

    If I can change the sort method, How??
    Any help would be appreciated

    I stopped the application; Below is actual code.
    vb Code:
    1. Private Sub ChkNDX()
    2.     Dim Tst As Boolean
    3.     Call OpenConnection
    4.    
    5.     Tst = Mod007.CheckFileExist("c:\mv\xmvdetic.dbf")
    6.     If Tst = False Then
    7.         SQLst = "CREATE INDEX xmvdetic " & _
    8.                 "ON mvdetail (det_icode)"
    9.         CN.Execute SQLst
    10.     End If

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Creating Index (problem ??)

    I don't think you could change the method used to sort/create the index file, as that will be part of the internal processes (there may be extra switches for Create Index, but I have no idea what they might be).

    Your code means almost nothing to us, as you have not shown the two functions you used (which may well be causing problems), or told us where it is 'stuck' (I presume on line 9, but can't be sure).

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Re: Creating Index (problem ??)

    your assumption is correct
    line nine is where it is hanging, but no error.

    OpenConnection sub is tried and true. It does just that, open my db connection. If you want to see it I'll post it, but I know it works as I have used it in other apps.

    ChkFileExist returns True if there is a file by that name and false if it doesn't exist. Again tried, true, and used in other apps.

    I do think that the app is working properly, just doing it slowly. If there is a way in which to speed it up, that would be great. However, I'm more than likely going to leave the app running all night and check it in the morning. Hopefully, it will be finished and I'll never have to re-create the whole index just do small updates.

    Anyway, I'll post back the results in the morning.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Re: Creating Index (problem ??)

    It ran all night (5:00pm - 7:20am), a little over 14 hours and did not get past line 9.

    I have the sub,function, and original code I posted.
    VB Code:
    1. '--------------------------------------------------------------------
    2. 'Opens the connection to tables
    3. Private Sub OpenConnection()
    4.     Dim Temp As String
    5.     If CN.State <> 0 Then       '-----------------------------------
    6.         CN.Close                    'makes sure connection is closed
    7.     End If                      '-----------------------------------
    8.    
    9.     Temp = "Driver={Microsoft dBASE Driver (*.dbf)};" & _
    10.             "DriverID=21;Fil=(dBase III);defaultdir=" & _
    11.             StorePath & ";readonly=false"
    12.     CN.Open Temp                                            'Opens Connection
    13. End Sub
    14.  
    15. '-------------------------------------------------------------------------
    16. Public Function CheckFileExist(Path As String) As Boolean
    17.     If Dir$(Path) <> vbNullString Then
    18.         CheckFileExist = True
    19.     Else
    20.         CheckFileExist = False
    21.     End If
    22. End Function
    23.  
    24. '--------------------------------------------------------------------
    25. Private Sub ChkNDX()
    26.     Dim Tst As Boolean
    27.     Call OpenConnection
    28.          
    29.     Tst = Mod007.CheckFileExist("c:\mv\xmvdetic.dbf")
    30.      If Tst = False Then
    31.          SQLst = "CREATE INDEX xmvdetic " & _
    32.                      "ON mvdetail (det_icode)"
    33.          CN.Execute SQLst                       '<===== Line getting 'stuck' on
    34.      End If
    35. end sub

    cn.execute sqlst - Is the line getting stuck on
    Last edited by re_turner_jr; Sep 26th, 2007 at 12:01 PM.

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