mysql 300万数据查询500多秒怎么优化啊

本帖最后由 dz215136304 于 2013-08-15 11:33:52 编辑

linux下 mysql 300万数据查询500多秒怎么优化啊,其中pid已经做索引,id是主键

SELECT id,pid,keyWords,shortUrl FROM  keywords  WHERE pid=0 ORDER BY id DESC LIMIT 50

explain 如下:

mysql> explain SELECT id,pid,keyWords,shortUrl FROM  keywords  WHERE pid=0 ORDER BY id DESC LIMIT 50;

+----+-------------+----------+------+---------------+------+---------+-------+---------+-----------------------------+

| id | select_type | table    | type | possible_keys | key  | key_len | ref   | rows    | Extra                       |

+----+-------------+----------+------+---------------+------+---------+-------+---------+-----------------------------+

|  1 | SIMPLE      | keywords | ref  | pid           | pid  | 4       | const | 2452523 | Using where; Using filesort |

+----+-------------+----------+------+---------------+------+---------+-------+---------+-----------------------------+

1 row in set (8.18 sec)

另外mysql cpu占用很高怎么回事?内存:512M

配置文件如下:

# Example MySQL config file for small systems.

#

# This is for a system with little memory (<= 64M) where MySQL is only used

# from time to time and it's important that the mysqld daemon

# doesn't use much resources.

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is /usr/local/mysql/var) or

# ~/.my.cnf to set user-specific options.

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

#password= your_password

port= 3306

socket= /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port= 3306

socket= /tmp/mysql.sock

skip-locking

key_buffer = 16K

max_allowed_packet = 1M

table_cache = 4

sort_buffer_size = 64K

read_buffer_size = 256K

read_rnd_buffer_size = 256K

net_buffer_length = 2K

thread_stack = 64K

datadir=/www/mysql/data

log-slow-queries=/www/log/mysql/slowquery.log

long_query_time=2

# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on Windows

# (using the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

server-id= 1

# Uncomment the following if you want to log updates

#log-bin=mysql-bin

# Uncomment the following if you are NOT using BDB tables

#skip-bdb

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = /usr/local/mysql/var/

#innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = /usr/local/mysql/var/

#innodb_log_arch_dir = /usr/local/mysql/var/

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 5M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

PHP群发300万,mysql 300万数据查询500多秒如何优化相关推荐

  1. python连接MySQL并进行数据查询

    python连接MySQL并进行数据查询 #建立数据库的连接 mydb = mysql.connector.connect(host="0.0.0.0",user="ro ...

  2. 【MySQL练习】数据查询(02)-简易版

    ---------------------MYSQL练习题:数据查询(02)-简易版---------------------- 提供了数据查询进阶版练习题的各种目录文件,便于对照自己思索练习: 增强 ...

  3. Mysql数据库入门---数据查询常用方法(包含条件查询和排序查询)

    Mysql数据库入门-数据查询 Author:qyan.li Date:2022.2.21 文章目录 ``Mysql``数据库入门---数据查询 1. ``select``关键字 2.条件查询 3.排 ...

  4. MySQL中的数据查询

    文章目录 1 简单查询 1.1 查询所有字段数据 1.2 查询指定字段数据 1.3 DISTINCT查询 1.4 IN查询 1.5 BETWEEN AND查询 1.6 LIKE模糊查询 1.7 对查询 ...

  5. 【Mysql】大量数据查询时的优化相关知识

    今天在查询大量数据时,遇到了查询速度较慢的问题,特地搜集整理了相关的问题解决办法. 一.对于sql的优化 1 使用explain判断sql语句是否使用了索引 1. explain能够干什么 读取表的顺 ...

  6. MySQL:DQL 数据查询语句盘点

    本篇内容包括:DQL 的简介.SELECT 语句.WHERE 条件语句.JOIN 连接查询(多表查询)和分组.过滤.排序.分页.子查询的使用. 一.DQL 简介 DQL(Data QueryLangu ...

  7. 【MySQL】mysql:重复数据查询 sql

    目录 一.准备测试表 (1)创建表 (2)查询表 (3)删除表 二.准备测试数据 (1)插入数据 (2)查询数据 三.重复数据查询 (1)查询 numid 相同,而 testname 不同,不包括同 ...

  8. mysql 高并发下查询很慢_MySQL-高并发优化

    一.数据库结构的设计 1.数据行的长度不要超过8020字节,如果超过这个长度的话在物理页中这条数据会占用两行从而造成存储碎片,降低查询效率. 2.能够用数字类型的字段尽量选择数字类型而不用字符串类型的 ...

  9. mysql 5亿数据 查询_日均5亿查询量的京东订单中心,为什么舍MySQL用ES?

    来源:京东技术订阅号(ID:jingdongjishu) 京东到家订单中心系统业务中,无论是外部商家的订单生产,或是内部上下游系统的依赖,订单查询的调用量都非常大,造成了订单数据读多写少的情况.我们把 ...

最新文章

  1. 学习数据结构 二叉查找树(binary search tree)
  2. LuManager使用中典型问题整理集合
  3. 关于拖拽上传 [一个拖拽上传修改头像的流程]
  4. 大二暑假周进度总结07
  5. 并发编程(多进程1)
  6. vue 项目难点_Vue 项目里戳中你痛点的问题及解决办法
  7. 数字PCR的特点、优势和局限性浅析
  8. 百度应用市场app认领操作
  9. 【Vue学习笔记_05】v-on事件监听
  10. IE浏览器打开github点击code无响应
  11. c++中的 trivial destructor
  12. xiuno开发文档_XiunoPHP4.0开发手册 | 雷雨博客
  13. Ian Goodfellow回忆GAN诞生故事:几杯啤酒喝出“20年来最酷的深度学习想法”
  14. 服务器主板安装win10系统,装win10主板怎么设置_装win10主板设置教程 - 系统家园...
  15. 海量CAD图纸哪里获取呢?
  16. CRC 循环冗余校验码 的计算方法
  17. SOFABoot源码解析之模块化开发
  18. c#连接读取mysql内容(报警无法连接处理方法)
  19. 关于在ICEM中导入CAD几何模型文件的问题
  20. 电脑微软账户登录一直转圈怎么解决问题

热门文章

  1. Ubuntu上 anaconda的卸载
  2. ROS仿真-记一次错误 gazebo-2 process has died exit code 2
  3. Python画各种 3D 图形Matplotlib库
  4. MongoDB高级——聚合
  5. Pycharm结合Anaconda结合使用下的能够产生作用的Anaconda命令
  6. PRML-系列一之1.2.1
  7. C++中序列化对象并存储到mysql
  8. php header函数的详解,php header函数的详解_PHP教程
  9. python 32位软件下载安装_Python32位官方下载-Python(开发环境工具)v3.9.1 x32 官方win版-ucbug软件站...
  10. [论文阅读][SLAM]Targetless Calibration of LiDAR-IMU System Based on Continuous-time Batch Estimation