hibernate跟jdbc的查詢速度相差10???

neuhawk發表於2003-08-27
我按照robbin的程式測試。
查詢1000條紀錄:(hibernate使用list)
Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 311ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 1362ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 461ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 70ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 631ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 70ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 80ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 441ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 270ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 70ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 461ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 50ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 70ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 591ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 60ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 60ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 591ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 60ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 80ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 441ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 50ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 210ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 461ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 80ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 60ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 591ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 50ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 70ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 441ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 60ms


//////////////還有ms的驅動也不是很差阿。

而如果查詢100條紀錄,在cat.hbm.xml增加jcs-cache usage="read-only"
而hibarenate改成
Iterator iter = q.iterate();(是不是這樣用jcs??)


測試結果
Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 80ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 862ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 230ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 20ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 641ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 20ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 40ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 701ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 20ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 0ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 681ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 20ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 0ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 561ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 60ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 0ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 541ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 0ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 0ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 681ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 0ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 10ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 571ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 10ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 0ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 561ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 0ms

Start Reading Records with JSQL JDBC...

Finished Reading Records with JSQL JDBC: 10ms

Start Reading Records with Hibernate...

Finished Reading Records with Hibernate: 551ms

Start Reading Records with MS JDBC...

Finished Reading Records with MS JDBC: 0ms


/////////////////為什麼呢?hibernate我用的是jsql的驅動。

相關文章