RSS feed [root] /database /weblog



title search:


Sat Sep 09 00:15:42 HKT 2017


(google search) (amazon search)
download zip of files only

Sat Mar 31 16:14:54 HKT 2018 From /weblog/database/vendor


SQL 2005 JDBC fix the resultset re-read throws exception problem. However, you need to use executeUpdate() for insert,update and delete instead of execute() for SQL 2005 JDBC, otherwise will throw exception on this.

Other that, statement.executeBatch() will throws exception:[..]kid=e13a8009-7466-4803-ba19-6bfd4b5f8966

New function of SQL server 2014, In-Memory Optimization tables, suppose to be faster? - MOT table also support native compiled query - , and lock free write?

From microsoft, Use the columnstore index to achieve up to 10x query performance gains over traditional row-oriented storage, and up to 7x data compression over the uncompressed data size. -

A tool from M$ to help sql server user to manage change of database: . Other similar product is DBGhost, also only work for SQL server

There is a free version of SQL server 2005 call SQL server express, which just like MSDE

Here is a comparison:[..]le/ArticleID/49618/sql_server_49618.html , may be we can use that instead of MSDE 2005 and discoutinue support of SQL server 2000 so that we can test one thing less?

Import CSV to SQL server -[..]oad-comma-delimited-file-csv-in-sql.html

Shriking DB cause performance problem... not sure how long this finding is hold -[..]eases-fragmentation-reduces-performance/[..]ver-storage-internals-part-1-basics.aspx

Get the metadata -[..]-metadata-from-sql-server-catalog-views/[..]icrosoft-sql-server-metadata-developers/

Date functions -[..]roduction-to-sql-servers-date-functions/

Enhancement of 2016 -

Tool to rescue sql server -

Prevent locking with NOLOCK / READPAST -[..]-and-readpast-table-hints-in-sql-server/

(google search) (amazon search)

Tue Feb 06 00:00:21 HKT 2018 From /weblog/database/performance

Note of SQL performance tuning

Note of this book -

1) Order of "and" and "or" is matter, if no cost-base optimizer

where column1 = 'a' and column2 = 'b' -> where column2 = 'b' and column1 = 'a' if column2 'b' is less likely

2) <> is more expensive than =

3) Can force to use index if SELECT * FROM table WHERE indexed_column > 0

4) UPPER(column) might lose information, use LOWER is better

5) WHERE column = 'WORD' or column = 'word' is always faster than WHERE LOWER(column) = 'word' , even faster version is test if database if case-insensitive: WHERE column = 'WORD' or ('WORD' <> 'word' AND column = 'word')

6) 32bit integer is the fastest datatype for 32bit OS

7) column in (?, ?) is faster than column =? or column = ? for some database, and don't slow in any database

8) For aggregate functions, prevent using having, try to use fewer columns in group by and use subquery if possible

9) In fact, count(1) is not faster than count(*)

10) CAST before aggregate function: SELECT CAST(SUM(column) AS INT) -> SELECT SUM(CAST(column as INT))

11) Use constant as much as possible, e.g.: select * from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1 -> select * from t1, t2 where t1.c1=1 andn t2.c1=1

12) Information of Join vs Subqueries

13) Information of optimum column type (VARCHAR, TIMESTAMP, WORD size INT and CHAR(1) usually better), shift effect for page

14) prevent NULL for porting issue

15) Low level table physical information

Some related links -[..]9/12/sql-optimization-tipsquestions.html

16) Prevent database level transaction, prevent joining, prevent locking ( like auto increment key ), pretty good suggestion -

17) Reduce dataset for aggregation -[..]-subqueries-to-count-distinct-50x-faster

Few good tips, like avoid cursors -[..]ent/21-rules-for-faster-sql-queries.html

(google search) (amazon search)

Fri Nov 03 09:41:42 HKT 2017 From /weblog/database/performance


(google search) (amazon search)

Fri Sep 22 15:29:28 HKT 2017 From /weblog/database/performance


IT Hare: Ultimate DB Heresy: Single Modifying DB Connection. Part I. Performanc -[..]y-single-modifying-db-connection-pa.html

How yandex.metrica improve DB reading -[..]of-data-structures-in-yandexmetrica.html

(google search) (amazon search)

Sat Sep 09 00:15:42 HKT 2017 From /weblog/database


If using uuid as PK is good idea? -[..]-as-primary-keys-be-careful-7b2aa3dcb439

(google search) (amazon search)

Sun Aug 06 09:37:23 HKT 2017 From /weblog/database/transaction


Transaction, same as all the concept in computing, is an approach and trade-off -[..]

Transaction file system -

Explanation about database isolation level -[..]-and-their-effects-on-performance-a.html[..]08-01-practical-guide-sql-isolation.html

A nice article explain about transaction process -[..]Nuts-and-Bolts-of-Transaction-Processing[..]guide-to-acid-and-database-transactions/

(google search) (amazon search)

Wed Jul 26 10:57:03 HKT 2017 From /weblog/database

time series

Some information about Time Series:[..]ocs/cd/A87860_01/doc/inter.817/index.htm[..]1/time-series-forecasting-part-1_23.html

Discussion of time in time series database - UTC or local -[..]ime-in-time-series-database-utc-or-local

Market data:

and a book:[..]iented-database-applications-in-sql.html

Should we use DATE as key or INT as key?[..]senting-time-series-implementation-level

Collections of column-oriented stores -[..]s/1392/usage-of-nosql-storage-in-finance

时序数据库深入浅出之存储篇 -

深入浅出时序数据库之压缩篇 -

pretreatment -[..]les/pretreatment-in-sequential-databases

Why -

分级存储 -[..]archical-storage-of-sequential-databases

(google search) (amazon search)

Wed Feb 22 15:10:51 HKT 2017 From /weblog/database/vendor


Few distributed SQL DB vendor information -

Approximation DB -[..]e-200x-faster-without-having-to-pay.html

Discuss and compare difference technology of querying journey(log) data -[..]on-log-and-data-storage-query-techniques

(google search) (amazon search)

Tue Jan 03 09:58:28 HKT 2017 From /weblog/database

database comparison

Wiki of common DBMS comparison -[..]rison_of_SQL_database_management_systems

Somebody comment that postgresql is less competency than MSSQL, see the comment

Alternative DBMS -[..]ternative-open-source-databases-engines/[..]0-most-popular-db-engines-sql-and-nosql/[..]2015/05/25/what-makes-a-solution-mature/

Comparing major RDBMS -[..]elect-the-appropriate-rdmbs-for-the-oltp

(google search) (amazon search)

Wed Oct 19 01:41:16 HKT 2016 From /weblog/database/vendor


PostgreSQL schema is way fast and easy to change than MySQL, although maybe slower -[..]grating-from-mysql-to-postgresql-slides/

Subindexes that can save you space and make updates faster by reusing an existing multi-column index.
Expression indexes that speed up queries with WHERE clauses matching a function of the columns instead of raw values.
Partial indexes that are much smaller than a complete index because they don't contain data that the app doesn't care about.[..]l-indexing-tricks-that-surprise-everyone

Experience sharing, stored proc is better?

(google search) (amazon search)

Thu Oct 13 08:33:54 HKT 2016 From /weblog/database


Berkeley CS286: Implementation of Database Systems, Fall 2014‎ > ‎

Disambiguating Databases, explaining various aspects of difference datastore approach -

Basic -[..]action-isolation-levels-and-concurrency/

(google search) (amazon search)

Thu Jun 23 07:23:32 HKT 2016 From /weblog/database/vendor


Some comment saying that you cannot complain oracle for non-standard setup... However, should I break anything else just to install oracle? Anyway, may be a useful resource of installing oracle cluster -

Oracle SQL links -

Pure java solution to full text search -[..]nning-lucene-inside-your-oracle-jvm.html

Oracle does allow definitions of user-defined types.Please see[..]er.111/b28286/sql_elements001.htm#i46376

User-defined types can then be used for column definitions. See e.g.
the fourth example given here[..].111/b28286/statements_7002.htm#i2062833

Oracle also allows creation of a table based on one user-defined type,
i.e. an "object table".
See here[..].111/b28286/statements_7002.htm#i2159410

User-defined types can be changed; see[..].111/b28286/statements_4002.htm#i2057828
Oracle even offers an option as to whether existing data in tables
based on previous type definition is converted or not; see[..].111/b28286/statements_4002.htm#i2079300
There are a couple of pages in the Object-Relational Developer's Guide explaining the consequences, briefly...

Note: all links above are to Oracle 11g documentation, but many, if not all, of these features have been available since 9i.

row base permission -[..]/oracle/virtual-private-database-oracle/

How fetch size can affect performance -[..]jdbc-performance-tuning-with-fetch-size/

Recycle bin for Oracle 10g -[..]ecycle-bin-in-database.html#.UNXprSUqthH

Oracle won't put null in index... how can we find the column with issue out? -[..]12/the-index-youve-added-is-useless-why/

You can have java like stacetrace at PLSQL -

Need to be careful about using rownum to limit the result in oracle -[..]racle-limit-returned-records-with-rownum

(google search) (amazon search)

Mon Jun 06 16:09:19 HKT 2016 From /weblog/database

database style

A pointer to various database style discussion, like [application database], [integration database], [silly database], [smart database] ...[..]n-of-stupid-databases-being-a-good-idea/

BDD for database design

Requirements are behavior,
Provides "ubiquitous language" for analysis,
Acceptance criteria should be executable.
Design constraints should be made into executable tests.


(google search) (amazon search)

Fri Jan 22 11:39:27 HKT 2016 From /weblog/database/sql


There is way to drop the dummy aggregate function in group by -[..]onal-dependencies-a-very-useful-feature/

(google search) (amazon search)

Fri Aug 28 18:19:53 HKT 2015 From /weblog/database/vendor


If you get following exception with Sybase ASE drive:

'System.Reflection.TargetInvocationException, Msg=Exception has been thrown by the target of an invocation.
Exception details: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Sybase.Data.AseClient.AseConnection' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'sybdrvado115a.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at ?.AseGetDriverVersion(StringBuilder A_0, Int32 A_1)
at Sybase.Data.AseClient.AseConnection.?()
at Sybase.Data.AseClient.AseConnection..cctor()
--- End of inner exception stack trace ---
at Sybase.Data.AseClient.AseConnection..ctor(String connectionString)

Please make sure the program can see sybdrvado115.dll, msvcp71.dll and msvcr71.dll in that same directory


Query to check blocking at sybase:
select spid,suser_name(suid),cmd,status,blocked,time_blocked,physical_io from master..sysprocesses where blocked <> 0

(google search) (amazon search)

Tue Jul 28 15:43:43 HKT 2015 From /weblog/database/performance


Case study about how to find out suitable index -[..]e+life+of+a+slow+page+at+Stack+Overflow#

A simple example of how to use EXPLAIN to find out the bottleneck of the query and add suitable index to suitable column -

Bitmap Index vs. B-tree Index: Which and When? -[..]/v5r3/index.jsp?topic=/rzajq/perf21c.htm

script to check if index is missing at foreign key

select table_name, constraint_name,
cname1 || nvl2(cname2,','||cname2,null) ||
nvl2(cname3,','||cname3,null) || nvl2(cname4,','||cname4,null) ||
nvl2(cname5,','||cname5,null) || nvl2(cname6,','||cname6,null) ||
nvl2(cname7,','||cname7,null) || nvl2(cname8,','||cname8,null)
from ( select b.table_name,
max(decode( position, 1, column_name, null )) cname1,
max(decode( position, 2, column_name, null )) cname2,
max(decode( position, 3, column_name, null )) cname3,
max(decode( position, 4, column_name, null )) cname4,
max(decode( position, 5, column_name, null )) cname5,
max(decode( position, 6, column_name, null )) cname6,
max(decode( position, 7, column_name, null )) cname7,
max(decode( position, 8, column_name, null )) cname8,
count(*) col_cnt
from (select substr(table_name,1,30) table_name,
substr(constraint_name,1,30) constraint_name,
substr(column_name,1,30) column_name,
from sys.user_cons_columns ) a,
sys.user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'R'
group by b.table_name, b.constraint_name
) cons
where col_cnt > ALL
( select count(*)
from sys.user_ind_columns i
where i.table_name = cons.table_name
and i.column_name in (cname1, cname2, cname3, cname4,
cname5, cname6, cname7, cname8 )
and i.column_position <= cons.col_cnt
group by i.index_name

Explain how postgres indexes work, look like combine index is not that useful -

(google search) (amazon search)

Sun Jul 05 08:25:32 HKT 2015 From /weblog/database


The Data Analytics Handbook -

(google search) (amazon search)

Tue Jun 09 17:22:45 HKT 2015 From /weblog/database


(google search) (amazon search)

Sat May 09 16:11:37 HKT 2015 From /weblog/database


Normally, we store object like


However, some say store as


is better for many cases...

ROW base DB are dead end? -

(google search) (amazon search)

Wed Jul 02 15:41:26 HKT 2014 From /weblog/database


Ruby tool to support Database versioning, look like this can work independence from Ruby on Rails -[..]&lr=&q=Ruby+Rails+Migrations&btnG=Search
An example coding with this tool -[..]7/activerecord-migrations-without-rails/

Links about Database versioning:

Eclipse plugin - but I cannot get it working, instead, work a lot better. However it is better to install using installation jars (and source) of SQuirreL, otherwise there may be version not map issue.

Another new tool, migrate4j -[..]12/23/simple-database-migration-in-java/

Comments of difference approach of DB deployment -[..]stration/database-deployment-challenges/

(google search) (amazon search)

Mon May 26 15:30:30 HKT 2014 From /weblog/database/vendor


It is surprising for me that it is this easy -

MySQL Proxy for table partition -

NoSQL way to access data in MySQL -[..]0/10/using-mysql-as-nosql-story-for.html

The lock level of mysql -[..]ql-transaction-isolation-levels-and.html

(google search) (amazon search)