高性能MySQL书籍(2004)的查询性能章节称MySQL(4.0.1)试图在查询缓存中找到任何"SELECT"查询的结果,然后再费心去分析或执行它.MySQL使用它收到的确切查询文本,因此缓存是敏感的,这意味着
SELECT * FROM table1
Run Code Online (Sandbox Code Playgroud)
不同于
select * FROM table1
Run Code Online (Sandbox Code Playgroud)
我想知道MySQL 5.x中是否仍然如此,所以我们应该总是键入'SELECT'而不是'select'.
我的MySQL数据库有超过100万条记录,而且越来越多.我有一个值"援助",有时可以多次使用.我想算援助.
我试过了
SELECT COUNT ( DISTINCT (value) ) AS somevalue
FROM table
Run Code Online (Sandbox Code Playgroud)
哪个有效,但现在有这么多的值,它需要比max_exec_time更长的时间.我也尝试过与GROUP BY相同而没有成功.
有没有办法快速运行此查询?或者还有其他解决方案吗?
我通常使用varchar字段的最大字符,所以在大多数情况下我设置255但在列中只使用16个字符...
这会降低我的数据库的性能吗?
我有一个大型表格,有200多个问题.将所有这些存储在一个表中是否存在问题?有没有更好的办法?
如果有另一个包含值的表,例如QuestionID,QuestionAnswer,会不会更好?
将它保存在一个表中肯定会更容易,所以只是寻找方向以防止以后后悔:)
我在magento应用程序(社区版)上拥有大约2.5个lachs(250K)产品和2600个子类别.
询问
SELECT 1 status
, e.entity_id
, e.type_id
, e.attribute_set_id
, cat_index.position AS cat_index_position
, e.name
, e.description
, e.short_description
, e.price
, e.special_price
, e.special_from_date
, e.special_to_date
, e.cost
, e.small_image
, e.thumbnail
, e.color
, e.color_value
, e.news_from_date
, e.news_to_date
, e.url_key
, e.required_options
, e.image_label
, e.small_image_label
, e.thumbnail_label
, e.msrp_enabled
, e.msrp_display_actual_price_type
, e.msrp
, e.tax_class_id
, e.price_type
, e.weight_type
, e.price_view
, e.shipment_type
, e.links_purchased_separately
, e.links_exist
, e.open_amount_min
, e.open_amount_max
, e.custom_h1
, …Run Code Online (Sandbox Code Playgroud) 我有一个订单表。该表属于多租户应用,因此同一表中存在来自多个商家的订单。该表存储了数亿条记录。这个问题有两个相关的列:
我想知道是否有一个有效的索引来执行以下操作:
SELECT * FROM <table> WHERE TransactionID = 'ff089f89feaac87b98a' AND MerchantID = 24更多信息:
oracle indexing database-design hashmap database-performance
我目前正在计划一个社交媒体应用程序 - 尤其是后端.基本上我有我想要使用SQL的所有社交方面(我猜是PostgreSQL),但我也有列表中的地理位置组织(这么多对一),这将很可能得出最大的数据量.我知道PostgreSQL有用于GIS功能的模块,我最初的想法只是为了简单而使用PostgreSQL,只是为了简单起见,因为Geolocation搜索的性能对于两个系统都应该是相同的,如果不支持PostgreSQL的话.我也可以在PostgreSQL中使用JSON Type,因此它基本上具有MongoDB所涵盖的最明显的优势.
另一方面,我担心可伸缩性,因为地理定位将成为最大的数据块,并且表格可能会有很多行.
所以我现在的想法是在MongoDB中实现地理定位,具有易于扩展,易于使用的地理位置搜索,并嵌入例如评论/喜欢地理定位直接进入文档,这将使地理定位读取/搜索更容易,但我再次不得不将这些数据与来自SQL的社交数据相结合,例如,获取评论地理位置的所有用户,并从PostgreSQL获取他们的个人资料信息并"手动"组合它.尽管部分可以在前端完成,但为我节省了大量资源.
我不确定这个想法有多好,如果我真的在那里帮忙.
postgresql scalability geolocation mongodb database-performance
我正在针对我的 MongoDB 运行测试,由于某种原因,find其性能与count.
统计数据:订单集合大小:~20M,product_id 6 的订单:~5K
对product_id 建立索引以提高性能。
查询:db.orders.find({product_id: 6})vsdb.orders.find({product_id: 6}).count()
结果 0.08ms 后产品订单与 5K 的结果
为什么计数没有显着加快?它可以使用product_id索引找到第一个和最后一个元素的位置
我正在构建一个Twitter应用程序,在twitter上显示已发布的链接,但我在按时间排序表时遇到问题.
tweet
+----------------------------------------+
| tweet_id | [...] | created_at |
+----------------------------------------+
| 123456 | [...] | 2012-06-11 11:31:28 |
| 234567 | [...] | 2012-06-11 11:32:55 |
| 345678 | [...] | 2012-06-11 11:33:22 |
+----------------------------------------+
tweets_url
+---------------------+
| tweet_id | url |
+---------------------+
| 123456 | cnn.com |
| 123456 | fox.com |
| 234567 | abc.com |
| 345678 | abc.com |
+---------------------+
Run Code Online (Sandbox Code Playgroud)
继承我的SQL(我使用GROUP by只返回唯一的URL):
SELECT tweet_urls.url,
FROM `tweets`
LEFT JOIN tweet_urls ON tweet_urls.tweet_id = tweets.tweet_id
WHERE tweet_urls.url …Run Code Online (Sandbox Code Playgroud) 我有一个结构如下的查询:
select (select first_name
from sub_table_1,
sub_table_2,
sub_table_3
where <where clause for sub_table 1,2,4>
and sub_table_1.col_1=table_1.col_1) first_name ,
(select last_name
from sub_table_1,
sub_table_2,
sub_table_3
where <where clause for sub_table 1,2,4>
and sub_table_1.col_1=table_1.col_1) last_name ,
<other select clause for table 1,2,3>
from table_1,
table_2,
table_3
where <Where clauses>
union
select (select first_name
from sub_table_1,
sub_table_2,
sub_table_3
where <where clause for sub_table 1,2,3>
and sub_table_1.col_1=table_4.col_1) first_name ,
(select last_name
from sub_table_1,
sub_table_2,
sub_table_3
where <where clause for sub_table 1,2,3>
and sub_table_1.col_1=table_4.col_1) last_name …Run Code Online (Sandbox Code Playgroud) 我正在尝试加快 Postgresq 插入速度。我看到很多文章都在使用 fsync、synchronous_commit 等。我设置了参数以获得最快的写入速度,而且我仍然听到 HDD 每次插入和数据库服务器肯定会执行 IO,就像缓冲区总是满的一样。我错过了什么?
create unlogged table ...;
-- just one insert takes about 400 ms
Run Code Online (Sandbox Code Playgroud)
postgresq 配置
wal_level = minimal
fsync = off
synchronous_commit = off
full_page_writes = off
wal_compression = off
wal_buffers = 128MB
wal_writer_delay = 1000ms
wal_writer_flush_after = 4MB
Run Code Online (Sandbox Code Playgroud) mysql ×4
sql ×4
mongodb ×2
postgresql ×2
geolocation ×1
hashmap ×1
indexing ×1
magento ×1
nginx ×1
oracle ×1
oracle11g ×1
performance ×1
php ×1
scalability ×1
sql-server ×1
time ×1