3 Replies Latest reply on Oct 28, 2013 6:12 AM by Kutir Mobility

    Rhom and create indexes

    David Miller

      Hi All

       

      I've hit that problem with sqlite when inserting >50k rows.  Inserts slow to near snail pace!  This occurs when the table is indexed.

      http://stackoverflow.com/questions/15778716/sqlite-insert-speed-slows-as-number-of-records-increases-due-to-an-index

       

      So, I've now got to come up with an alternative plan.  Create the indexes after the inserts are complete.

       

      Has anyone done this using execute_sql.  As in...

       

      Rhomobile | Using Rhom in Ruby

       

      ...and got some good results?

       

      And although, syntax wise, the guide says its executeSql, the other examples say execute_sql ????

       

      Anybody got sample Ruby code?

        • Re: Rhom and create indexes
          Kutir Mobility

          Hi David,

          Try as shown below,

                db = ::Rho::RHO.get_src_db('Category')

                db.execute_sql('CREATE INDEX "by_category" on Category ("phone", "name", "date")')

          RMS4.x only uses executeSql syntax.

          We will send a fix for the Rhomobile | Using Rhom in Ruby guide in the documentation.

           

          Visnupriya R

          Kutir Mobility

            • Re: Rhom and create indexes
              David Miller

              Hi

               

              Thanks for your reply.

               

              Actually I am using V4.0 and the correct syntax is execute_sql.   In fact the string content I am using is also different to your offering:

               

              db.execute_sql("CREATE INDEX IF NOT EXISTS barcodedata_barcode_no ON \"BarcodeData\"(\"barcode_no\")")

               

              When you submit a documentation update request, please ensure you specify the correct syntax to use.

               

              Rgds

               

              David

                • Re: Rhom and create indexes
                  Kutir Mobility

                  David,

                  RMS 4.0 API uses camelCase instead of snake_case.

                  The old syntax (execute_sql) will still work, but the new syntax (executeSql) should be used from now on.

                  Inside the rhodes-4.0.0 gem, in lib/commonAPI/coreapi/RhoDatabaseApi.rb you will see that the method is declared as executeSql as shown below,

                            # execute a sql statement

                            # optionally, disable the factory processing

                            # which returns the result array directly

                            def executeSql(sql, *args)

                                  _execute_sql(sql, false, args)

                            end

                            def executeBatchSql(sql, *args)

                                 _execute_sql(sql, true, args)

                            end

                            alias execute_sql :executeSql

                            alias execute_batch_sql :executeBatchSql