Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf

Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf

ID:34564883

大小:2.71 MB

页数:38页

时间:2019-03-08

Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf_第1页
Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf_第2页
Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf_第3页
Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf_第4页
Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf_第5页
资源描述:

《Postgres ConfChina2015_Victor_Handling_60million_likes_per_day_in_PostgreSQL.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、PostgreSQL见证每日6千万次"一见钟情”Handling60millionlikesperdayinPostgreSQLVictorBlomqvistvb@viblo.seblomqvist@tantanapp.comTantan(探探)November20,PGConf.CN2015inBeijingHowTantanworkstantanapp.com2"Wehavealreadyused17%ofthespaceinourrelationshiptable,anditsgrowin

2、gquickly"EmailsentonOctober312014tantanapp.com3Totalrelationshipsstored2,500,000,000sizeofinteger(2147483647)2,000,000,0001,500,000,0001,000,000,000500,000,0000tantanapp.com4TodayIwilltalkabouthowwegotTantantoscalefrom0to100160milliondailyswipes175,0

3、00,000150,000,000125,000,000100,000,00075,000,00050,000,00025,000,0000tantanapp.com5Like/dislikeotheruserstantanapp.com6Like/dislikeotherusers-TableCREATETABLErelationships(idserialPRIMARYKEY,user1integer,user2integer,statevarcharCHECK(stateIN('liked

4、','disliked')),);tantanapp.com7Like/dislikeotherusers-QueryINSERTINTOrelationships(user1,user2,state)VALUES(1,2,'disliked');tantanapp.com8Suggestusersforyoutantanapp.com9Suggestusersforyou-TableCREATETABLEusers(idserialPRIMARYKEY,namevarchar,genderva

5、rcharCHECK(genderIN('male','female')),ageinteger,locationgeometry,last_activetimestamp);tantanapp.com10Suggestusersforyou-QuerysetbeijingST_Point(116.454,39.9187)SELECT*FROMusersWHEREgender='female'ANDageBETWEEN22AND34ORDERBYST_Distance(location,:be

6、ijing)*(now()-last_active);tantanapp.com11Suggestusersforyou-Query(2)SELECT*FROMusersWHEREgender='female'ANDageBETWEEN22AND34ANDNOTEXISTS(SELECT*FROMrelationshipsWHEREuser1=1ANDuser2=users.id)ORDERBYST_Distance(location,:beijing)*(now()-last_active)L

7、IMIT20;tantanapp.com12Werunthe“suggest”query12milliontimesperday14,000,00012,000,00010,000,0008,000,0006,000,0004,000,0002,000,0000tantanapp.com13Whatisthefirstthingtodowhenthedatabaseisslow?tantanapp.com14Whatisthefirstthingtodowhenthedatabaseisslow

8、?CREATEINDEXusers_location_idxONusersUSINGGIST(location);CREATEINDEXrelationships_user1_idxONrelationships(user1);tantanapp.com15WITHindexed_queryAS(SELECT*FROMusersWHEREgender='female’ANDageBETWEEN22AND34ANDNOTEXISTS(SELECT*FROMrelationshipsWHEREuse

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。