Comments (1)
結論
- 作ったビューに対して
line.linename LIKE '東海道'
とかしてしまうと実行時間がとても遅くなることが分かった。- ちなみに
line NATURAL JOIN ...
すると若干は早い(でもちょっと遅い)
- ちなみに
- 一方
line.lineid=69
のように直接路線IDで引くと早いことが分かった。
実行環境
あと、X201s(Ubuntu 11.10 oneiric)で実行するとCore i7の威力なのかSQLite3のバージョンが3.7.3から3.7.7に上がったからか、めっちゃ早い。
- 一応実行計画読んでみたけど意味不明。
- Pythonで実験したところX201sでは25%程度のオーバヘッドが加わる。
- 一方T40 (Debian squeeze)ではidで引くと1秒/op.程度なのがname LIKEで11秒/op.になる。これはアーキテクチャというよりはSQLiteの実装がショボかったんではという気がしてくる。
結論としてはどうせlinenameでLIKEするうっかりさんはいるんだから最初からlineも結合しておけば便利なんじゃねという感じ。実験用のコードは下に示す。
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3
import time
DB = sqlite3.connect("ares.sqlite")
def lineid():
for i in range(100):
cur = DB.execute(u"SELECT * FROM station_kilo NATURAL JOIN line WHERE lineid=69")
for i in cur: pass
def linename():
for i in range(100):
cur = DB.execute(u"SELECT * FROM station_kilo NATURAL JOIN line WHERE linename LIKE '東海道'")
for i in cur: pass
def get_time(function):
begin = time.clock()
function()
end = time.clock()
return end - begin
print "lineid: ", get_time(lineid), "sec"
print "linename: ", get_time(linename), "sec"
from ares.
Related Issues (20)
- 運賃体系の見せ方・APIでの返し方 HOT 2
- JR四国・九州の閉じた経路に対応する。
- 本州地方交通線に対応する
- 電車特定区間・山手線・環状線に対応 HOT 1
- 特定都区市内制度
- googletestに変更するか
- C++03版の実装をしてみる HOT 1
- CDatabaseはget_company_and_kiloでキロではなく起点・終点を返す
- 三島会社と本州の乗り継ぎに対応
- JR北海道の閉じた経路に対応する。
- GUIのtoolkitの確認 HOT 1
- sqlite3_wrapperのUTF-8/UTF-16双方への対応
- sqlite3_wrapperのiterator実装を利用したaresの実装
- sqlite3_wrapperのiterator実装を見直す HOT 1
- 社線対応
- 特定の経路に対する特例
- wxAres運賃計算機能
- 左カラムの選択が重い HOT 2
- 検索APIのアーキテクチャ修正 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ares.