加载中…
个人资料
王斌科
王斌科
  • 博客等级:
  • 博客积分:0
  • 博客访问:36,206
  • 关注人气:163,639
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

Alchemy Database 使用SQL语句操作redis的内存数据库

(2012-01-13 09:38:49)
标签:

it

mysql

杂谈

分类: 数据库笔记

现介绍一款NB的DB(Alchemy Database)介绍给大家认识,这个世界上疯狂的人真多,尤其是这个老外,竟然把Redis改造成一个支持SQL语句的内存型数据库.

以下是官方网站提供的测试语句.

FAST ON COMMODITY HARDWARE:

Client/Server using 1GbE LAN to/from a single core running at 3.0GHz, RAM PC3200 (400MHz) 
95K INSERT/sec, 95K SELECT/sec, 90K UPDATE/sec, 100K DELETE/sec 
Range Queries returning 10 rows: 40K/sec 
2 Table Joins returning 10 rows: 20K/sec 
10 Table Joins returning 10 rows: 4.5K/sec 
Lua script performing read and write: 42K/sec

 

Supported SQL

Create/Drop Operations:

  • CREATE TABLE customer
(id INT, group_id INT, name TEXT, phone text, age INT);
  • CREATE INDEX cust_group_ind ON customer (group_id);
  • DROP TABLE customer
  • DROP INDEX cust_group_ind
  • DESC customer - provides detailed memory usage info
  • DUMP customer - dumps the table to client
  • DUMP customer TO MYSQL - dumps the table in mysql format
  • DUMP customer TO FILE fname - dumps the table to the file "fname"

Single Row Operations

  • INSERT INTO customer VALUES (1,300,’John Doe’,’301-933-1891begin_of_the_skype_highlighting            301-933-1891      end_of_the_skype_highlighting’,30);
  • SELECT group_id, phone FROM customer WHERE id = 1
  • DELETE FROM customer WHERE id = 1
  • UPDATE customer SET phone = ‘703-933-1891 begin_of_the_skype_highlighting            703-933-1891      end_of_the_skype_highlighting’, group_id = 4 WHERE id = 1
  • INSERT INTO customer VALUES (1,300,’John Doe’,’301-933-1891begin_of_the_skype_highlighting            301-933-1891      end_of_the_skype_highlighting’,30) RETURN SIZE; - returns the size of the row, table, and indices

Index Operations

  • SELECT group_id, phone FROM customer WHERE group_id BETWEEN 300 AND 400 [ORDER BY column LIMIT n OFFSET m]
  • SELECT group_id, phone FROM customer WHERE group_id IN (300, 301, 307, 311) [ORDER BY column LIMIT n OFFSET m]
  • DELETE FROM customer WHERE group_id BETWEEN 300 AND 400 [ORDER BY column LIMIT n OFFSET m]
  • UPDATE customer SET phone = ‘703-933-1891 begin_of_the_skype_highlighting            703-933-1891      end_of_the_skype_highlighting’, group_id = 4 WHERE group_id BETWEEN 300 AND 400 [ORDER BY column LIMIT n OFFSET m]
  • Introducing the Non-Relational Range Query - the IN() can contain ANY redis command that returns rows (e.g. LRANGE, SINTER, ZREVRANGE, etc...)
Get name and number of the 5 most recent active customers

<span class="pln">SELECT name</span><span class="pun">,</span><span class="pln"> phone FROM customer WHERE group_id IN </span><span class="pun">(</span><span class="pln">$LRANGE L_IND_recent_calls </span><span class="lit">0</span><span class="pln"> </span><span class="lit">5</span><span class="pun">)</span><span class="pln"> </span><span class="pun">[</span><span class="pln">ORDER BY column LIMIT n OFFSET m</span><span class="pun">]</span>

Update Expressions

UPDATE expressions currently support the following functionalities (+=, -=, *=, /=, %=, ^=, ||=)

<span class="pln">UPDATE customer SET phone </span><span class="pun">=</span><span class="pln"> phone </span><span class="pun">||</span><span class="pln"> </span><span class="str">' ext 912'</span><span class="pun">,</span><span class="pln"> group_id </span><span class="pun">=</span><span class="pln"> group_id </span><span class="pun">*</span><span class="pln"> </span><span class="lit">4</span><span class="pun">,</span><span class="pln"> age </span><span class="pun">=</span><span class="pln"> age </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> WHERE id </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span>

 

 

http://code.google.com/p/alchemydatabase/

0

阅读 评论 收藏 转载 喜欢 打印举报/Report
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有