数据库分片后的查询及join操作

15 views
Skip to first unread message

Abioy Sun

unread,
Nov 15, 2010, 10:23:05 PM11/15/10
to mys...@googlegroups.com
hi, all

这里都差不多长草了@_@
 
刚开始接触这方面的知识,了解到一些方案是加上一个中间层。不过对于这种情况,中间层似乎也不大好处理?
 
Q1:
怎么处理分库后的查询,如果该查询要求
1)有序
2)offset 及limit
例如,select * from xxxx where yyyy order by col_a asc limit num_b, num_c
如果都查num_b + num_c个后在中间层合并再取[num_b,num_b + num_c),效率似乎很低?
 
Q2:
不同库里,表的join操作又该如何处理?
 
还请各位指教,thx!
 
Abioy

sky.jian

unread,
Nov 22, 2010, 8:34:04 PM11/22/10
to mys...@googlegroups.com, Abioy Sun
A1��ֻ��ͨ����ڵ㲢��ȡ��ǰnum_c �������¼Ȼ���ڿͻ��ˣ�������ν���м���������鲢���߹鲢�߶�ȡ���90%���ϵij���Ч��Ӱ���С������ֻ��һ���鲢�������Դ��ĺ�һ�������� ��Դ����ġ�

A2�����˾��ã���ͬ��ݿ��еı�������ʵ��join��ֻ����дSQL�ڿͻ��ˣ�������ν���м�����Ͻ���Join

On 11/16/2010 11:23 AM, Abioy Sun wrote:
hi, all

���ﶼ��೤����@_@
 
�տ�ʼ�Ӵ��ⷽ���֪ʶ���˽⵽һЩ�����Ǽ���һ���м�㡣�����������������м���ƺ�Ҳ����ô��?
 
Q1��
��ô����ֿ��IJ�ѯ�����ò�ѯҪ��
1������
2��offset ��limit
���磬select * from xxxx where yyyy order by col_a asc limit num_b, num_c
����num_b + num_c�������м��ϲ���ȡ[num_b��num_b + num_c)��Ч���ƺ��ܵͣ�
 
Q2��
��ͬ������join�����ָ���δ��?
 
�����λָ�̣�thx!
 
Abioy
--
MySQLer �ʼ���
Ҫ���������뷢 Mail �� �ʼ����ʼ���ַ��mys...@googlegroups.com
Ҫ�˶����ʼ����뷢 Email �� mysqler+u...@googlegroups.com
Ҫ�˽������Ϣ������ʣ�http://groups.google.com/group/mysqler?hl=en
 
���������飺http://www.iMySQLer.com

Abioy Sun

unread,
Nov 24, 2010, 9:36:25 PM11/24/10
to sky...@gmail.com, mys...@googlegroups.com
嗯,看来只好这样了。在数据库查询语句上做一些优化,应该能把消耗减下来。
Reply all
Reply to author
Forward
0 new messages