diff options
| -rw-r--r-- | client/changes/feature_sqlite-optimization-pragmas | 1 | ||||
| -rw-r--r-- | client/src/leap/soledad/client/sqlcipher.py | 20 | 
2 files changed, 21 insertions, 0 deletions
| diff --git a/client/changes/feature_sqlite-optimization-pragmas b/client/changes/feature_sqlite-optimization-pragmas new file mode 100644 index 00000000..7a35f005 --- /dev/null +++ b/client/changes/feature_sqlite-optimization-pragmas @@ -0,0 +1 @@ +  o Add sync=off and tem_store=mem to soledad client, for optimization. diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index 43c871c3..ef059e9b 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -190,6 +190,10 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):              self._set_crypto_pragmas(                  self._db_handle, password, raw_key, cipher, kdf_iter,                  cipher_page_size) +            if os.environ.get('LEAP_SQLITE_NOSYNC'): +                self._pragma_synchronous_off(self._db_handle) +            if os.environ.get('LEAP_SQLITE_MEMSTORE'): +                self._pragma_mem_temp_store(self._db_handle)              self._real_replica_uid = None              self._ensure_schema()              self._crypto = crypto @@ -734,6 +738,22 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):          # XXX change passphrase param!          db_handle.cursor().execute('PRAGMA rekey = "x\'%s"' % passphrase) +    @classmethod +    def _pragma_synchronous_off(cls, db_handle): +        """ +        Change the setting of the "synchronous" flag to OFF. +        """ +        logger.debug("SQLCIPHER: SETTING SYNCHRONOUS OFF") +        db_handle.cursor().execute('PRAGMA synchronous=OFF') + +    @classmethod +    def _pragma_mem_temp_store(cls, db_handle): +        """ +        Use a in-memory store for temporary tables. +        """ +        logger.debug("SQLCIPHER: SETTING TEMP_STORE MEMORY") +        db_handle.cursor().execute('PRAGMA temp_store=MEMORY') +      # Extra query methods: extensions to the base sqlite implmentation.      def get_count_from_index(self, index_name, *key_values): | 
