Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

.DBF index design (performance question)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    .DBF index design (performance question)

    Two ways of doing the same thing, which one is faster/better/preferred for .DBF's in terms of performance considerations?

    Option A:
    Create one single index (based on two fields in the table) ie: set the index order expression to: ALLTRIM(KEYFOB) + "/" + ALLTRIM(INVOICE)

    Option B:
    First create an additional calculated field in table (based on two these two fields above)
    (And then assign the index order expression to this one single calculated field.....

    In option A, the index contains the expression.
    In option B, the calculated table field contains the expression.

    Is it more efficient to make an index out of two separate fields, or first combine these fields using a calculated field?

    Also, I'm wondering how either of these two scenarios would apply with regards to using Alpha DAO active linked SQL tables (and also the implications of "LQO Optimization?"
    (In the two methods above, all data and field types are type text/character.)
    Last edited by SNusa; 01-08-2014, 09:51 AM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

    #2
    Re: .DBF index design (performance question)

    Personally, I'd go for option B.
    Reason. Indices are ok, but work best when they don't have to go through another process like an expression.
    The data in the Calculated Field will be a fixed value, and you can test that value.
    Where possible, an index with as few characters as possible, so can you reduce the extraneous stuff like "/", which are a pita!
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    Comment


      #3
      Re: .DBF index design (performance question)

      Originally posted by Ted Giles View Post
      Personally, I'd go for option B.
      Reason. Indices are ok, but work best when they don't have to go through another process like an expression.
      The data in the Calculated Field will be a fixed value, and you can test that value.
      Where possible, an index with as few characters as possible, so can you reduce the extraneous stuff like "/", which are a pita!
      I was wondering about that (and new the first part about the "extra process performance hit."
      But what about the calculated field? Doesn't that extra calculated field become re-evaluated "perpetually?"
      Or does it only change when the fields (from which it is calculated) are actually created and then thereafter only if/when they get changed?
      And if it is perpetually "re-evaluated" (whenever the data is "referenced") but there is no change, does this mean the index does not get updated?
      I remember reading somewhere in these forums that calculated fields can cause problems when certain calculations (like date() and now() are used) ~ which in this instance they obviously are not. Nevertheless, this got me to wondering exactly when these fields are "evaluated."

      So I guess the another related question is: Exactly when do calculated fields (in tables) actually get updated? Is it only when a field is initially populated. (And if not, does each evaluation result in index updates if no changes in values are made to the calculated field?)

      Note: I'm pretty certain that using "default field values" won't work here, because the data is imported, not "entered" by a user.
      Robert T. ~ "I enjoy manipulating data... just not my data."
      It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
      RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

      Comment


        #4
        Re: .DBF index design (performance question)

        So I guess the another related question is: Exactly when do calculated fields (in tables) actually get updated? Is it only when a field is initially populated. (And if not, does each evaluation result in index updates if no changes in values are made to the calculated field?)
        I believe that the calculated field in a Table (not on the screen) gets updated when the components change. No change, no update, so it's a one time operation unless one of the fields is updated.
        You can try this by creating a calculated field in a table, do NOT run the Rules Update - and start entering data. Only the new data will be used in the calculated field.
        Indexes will be updated on change of value in a field, so either way, the overhead is the same.
        See our Hybrid Option here;
        https://hybridapps.example-software.com/


        Apologies to anyone I haven't managed to upset yet.
        You are held in a queue and I will get to you soon.

        Comment


          #5
          Re: .DBF index design (performance question)

          Alpha Five has a undocumented function it uses for building compound index's quickly,

          *concat keys(Field1,Field2,Field3....)

          You can see it used in some of the indexs Alpha5 builds for linking sets etc.
          It will build a key that will properly sort numeric and text values but do so very quickly.
          Using this function indexs based on multiple fields can be built with little additional overhead.

          After some work with the function I was able to figure out the following documentation.

          '*concat_keys only work on field values it does not work on variables.
          'The seperator character  is only added to fields under the defined field
          ' length after the a rtrim is performed on the value.
          'Leading spaces are retained trialing spaces are trimmed to make keys smaller
          ' when trialing spaces are trimmed the seperator character is added.
          'The seperator character is a ASCII value of 2. It can be generated with
          'the expression chr(2)

          'Numeric values are treated differently again. The trialing seperator character 
          'is always added. A letter prefix is added that denotes number of digits.
          'In this way numerica value are sorted correctly but leading zeros are not required.
          '
          ' 1 - 0
          ' 12 - a12
          ' 204 - b204
          ' 1078 - c1078
          ' 40997 - d40997
          ' and so on....

          '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          '! *concat_keys only work on field values it does not work on variables !
          '! we are recreating key that Matches one created by it !
          '! the seperator character  is only added to fields under the defined field length !
          '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          'Sample index defination
          'Table: a-patients
          'Index: _PIDsitecd
          'Expression: *CONCAT_KEYS(PATIENTID,SITERETRIEVEDFROM,CODE)

          'Lookups Keys for these indexs can be easily built if
          'the source values are fields of the same length


          'Lookup Keys can be built using variables
          'using the following expression
          'it is assumed each variable has all trialing spaces removed
          'in this sample the DstSite is orginated as number that will always
          'be shorted then the field that that orginated the number
          'therefore seperator will always be added in index

          'Where ID and DstCode is character string of up to 8 characters long
          'Site is a single digit numeric value

          SP = CHR(2)
          Key = ID + IIF(len(ID)<8,SP,"") + alltrim(DstSite) + SP + DstCode + IIF(len(DstCode) < 8,SP,"")

          Comment


            #6
            Re: .DBF index design (performance question)

            This is good to know! (Wish I had learned this earlier/prior to having delved in as deeply to my "lifelong project" as I already have...... LOL)
            Good thing is, this change is fairly simple as the way I use combined indexes (combined field method is what I chose) only effects hand written code (and a few calculated fields)....

            @Paul - Just a thought here relating to you index naming conventions...

            You're using Index: _PIDsitecd
            From all that I've read here over the years, you're better off naming indexes with an underscore at the end of the name, not the beginning! ~ I use 2 underscores at the end so my created indexes stick out! Reason being is that Alpha has been known to truncate indexes. Someone please correct me, but I believe that 10 characters is the max before you have to worry about this happening. (Maybe 8 even????)

            TIP: I've also adopted the habit of using the field name as the index name (without the vowels unless it's the first letter) to shorten it down/belo to the 10 character limit.
            (I always shoot for 8 just to be "safe.")

            On that note: Anybody know whether indexes are still getting truncated? And if so is it at 10 chars, or 8?
            Robert T. ~ "I enjoy manipulating data... just not my data."
            It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
            RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

            Comment


              #7
              Re: .DBF index design (performance question)

              Robert,

              I think Alpha uses the FoxPro 2.6 format for DBF, FPT and CDX files. Indextags are limited to 10 chars in width in the Foxpro system. Alpha supports longer indextag names by storing part of the tag name in the dictionaries supporting the DBF file to which the CDX is attached. Truncation occurs when the DBF and CDX files get separated /disconnected from their dictionaries. The same issue will occur with fieldnames in the DBF files themselves. Long fieldnames in the DBF are stored in the supporting dictionaries.

              If you use long fieldnames and long indextag names Alpha must do a bit of extra work each time data entry occurs. The supporting dictionaries must be searched for the correct "long" fieldname or indextag names in order to complete data entry to the DBF and update the CDX. This happens quickly of course, but can be eliminated entirely by using short field and tag names.

              Comment


                #8
                Re: .DBF index design (performance question)

                RE: *Concat_Keys()

                Is this function being used to define an index definition within the table itself?
                I'm hoping it's suitable for generating an index that combines two fields (both character fields) where all values in each respective field are equal in length.

                If so I"m thinking about defining the indexes so that I can retrieve data using the following methods/functions:

                vc_Value = lookupC() ~ retrieve value in table
                vn_Results = <obj>.fetch_find() ~ to if/see how many entries in query exist

                Wow, just realized I can do this with a set too? (Open a set, and use set.fetch_find())..... Generally speaking, Is opening sets like that even a good idea? (If so, only for reading and not writing data?)
                Robert T. ~ "I enjoy manipulating data... just not my data."
                It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                Comment


                  #9
                  Re: .DBF index design (performance question)

                  Originally posted by Tom Cone Jr View Post
                  Robert,

                  I think Alpha uses the FoxPro 2.6 format for DBF, FPT and CDX files. Indextags are limited to 10 chars in width in the Foxpro system. Alpha supports longer indextag names by storing part of the tag name in the dictionaries supporting the DBF file to which the CDX is attached. Truncation occurs when the DBF and CDX files get separated /disconnected from their dictionaries. The same issue will occur with fieldnames in the DBF files themselves. Long fieldnames in the DBF are stored in the supporting dictionaries.

                  If you use long fieldnames and long indextag names Alpha must do a bit of extra work each time data entry occurs. The supporting dictionaries must be searched for the correct "long" fieldname or indextag names in order to complete data entry to the DBF and update the CDX. This happens quickly of course, but can be eliminated entirely by using short field and tag names.
                  The "magic number" is 10. Thanks Tom.
                  Robert T. ~ "I enjoy manipulating data... just not my data."
                  It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                  RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                  Comment


                    #10
                    Re: .DBF index design (performance question)

                    Talking about LQO:
                    Who started that? I was of the thought it was started with clipper87 and borrowed by FoxPro prior to ms acquisition of FoxPro and the whole thing started with another database type that is not used anywhere now to my knowledge. I do not remember the other database type, but is was super quick. It was limited as to record count though.

                    Got it: BTREE or Btrieve
                    Last edited by DaveM; 02-10-2015, 05:50 PM.
                    Dave Mason
                    [email protected]
                    Skype is dave.mason46

                    Comment


                      #11
                      Re: .DBF index design (performance question)

                      Originally posted by DaveM View Post
                      Talking about LQO:
                      Who started that? I was of the thought it was started with clipper87 and borrowed by FoxPro prior to ms acquisition of FoxPro and the whole thing started with another database type that is not used anywhere now to my knowledge. I do not remember the other database type, but is was super quick. It was limited as to record count though.

                      Got it: BTREE or Btrieve
                      Btrieve was pretty darn reliable. (At least from my perspective as a software user.) I never worked with it on the coding side.
                      But I spent the better part of 20 years using an accounting program that was Btrieve based.

                      My "lifelong winter/seasonal project:" (All the difficult stuff is behind me as of this evening!!! LOTS of trickery and xbasic on this monster form!)
                      This beast was a "mathematical nightmare... So much data to process and a very complicated form doing many things...
                      All hand coded xBasic, and virtually everything (including button text) is dynamically driven via data tables.
                      Have to clean up and "lock down" the form.... Create a few simple forms for editing the setup tables too. (and finish the last two tabs for import/admin etc.)
                      And replace a few "hard coded spots" with user defined variables....
                      ~ Relatively speaking, not much to it!

                      Capture2.PNGCapture3.PNGCapture4.PNG
                      Attached Files
                      Last edited by SNusa; 02-10-2015, 10:32 PM.
                      Robert T. ~ "I enjoy manipulating data... just not my data."
                      It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                      RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                      Comment


                        #12
                        Re: .DBF index design (performance question)

                        I use a Btrieve database - sorry to say. It is however very reliable and very fast, just limited in what it can do. And finding anyone who can develop in it - impossible!
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment


                          #13
                          Re: .DBF index design (performance question)

                          The company I worked for was using it before I got there. We still had to use it for a while. It was built with ms version of basic as the front. The only complaint ever was that it was difficult to work on and it was limited by size.
                          We were moving to Visual basic and ms access tables with the new desktop app to replace the old and adding crystal report writer(my job along with sales and installation).
                          I built over 1200 reports for the company and averaged 3 sales and installs per week.

                          The translation from the Btrieve to access for existing customers was huge and very difficult.
                          Dave Mason
                          [email protected]
                          Skype is dave.mason46

                          Comment


                            #14
                            Re: .DBF index design (performance question)

                            Translation is possible? I am happy to be converting text files from its reports into importable data...
                            Robin

                            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                            Comment


                              #15
                              Re: .DBF index design (performance question)

                              Robin,
                              The programmer in charge of that at the time, wrote some code that would be run at the client's site that would import the betrieve into the access tables. I know it was difficult to build, but it was not in my area of work. He passed away in 2003. I remember that he used a 2 step process like, to text and then to access.
                              Dave Mason
                              [email protected]
                              Skype is dave.mason46

                              Comment

                              Working...
                              X