background image

4.数据库优化:

表 

PRODUCT(ID,NAME,PRICE,COUNT);

在执行一下查询的时候速度总是很慢:

SELECT   *   FROM   PRODUCT   WHERE 
PRICE=100;

在 price 字段上加上一个非聚簇索引,查
询速度还是很慢。

   (1)分析查询慢的原因。

   (2)如何进行优化。

5.CREATE TABLE topid{

topicId   int   not   null   primary   key 
auto_increment,

title text,

author varchar(30),

content blob,

isDeleted int

......   //好像在 author 上定义了一个索引

}

CREATE TABLE reply{

topicId int foreign key,

replyId int primary key auto_increment,

replyAuthor varchar(30),

replyTime datetime,

context blob

....... //定义了一个索引和 key

}

一个为主题表,一个为回复表。

1.问从性能上考虑,这样做有什么不足。

2.查询回复时间不超过一个特定的时间段,
回复的作者名字以 MIKE 开头的主题

   的 title,以如下的查询:

   select * from topic where replyid in (select 
replyid from reply where

      replyAuthor   like   'mike%'   and 
(currentTime()-replyTime<specialTime))

   从性能上考虑上述的查询语句有什么不
足?

   如何进行优化?

--------------------------------------------------------
------------------------

php 中 empty(),is_null(),isset(),bool 之
间的区别

 

假设 $var 是任何 type。