Mysql的VIEWS与PHP查询 [英] Mysql VIEWS vs. PHP query

查看:142
本文介绍了Mysql的VIEWS与PHP查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,是指在各种列表,如乔的必游之地创造餐厅列表中的Web应用程序。现在,每一个餐厅和列表,我在网站上显示,它计算

I am working on a web application which involves create list of Restaurants in various lists like "Joe's must visit places". Now for each Restaurant and list, I have display on website which calculates


  • 餐厅的计算普及

  • 列表的普及

  • 列表的数目餐厅是present

目前我使用MySQL语句在PHP这个计划,但要切换到MySQL的意见,并做一个简单的SELECT语句在PHP ...

Currently I am using MySQL statements in PHP for this but planning to switch to MySQL VIEWS and do a simple select statement in PHP...

我的问题是,
什么是使用过写入SQL查询意见PHP的优势/劣势?

推荐答案

使用视图增加了抽象的级别:你以后可能会改变你的表的结构,你不会有改变code,它显示有关列表中的信息,因为你仍然会查询视图(视图定义可能会改变,虽然)。

Using views adds a level of abstraction : you may later change the structure of your tables, and you will not have to change the code that displays the information about the lists, because you will still be querying the view (the view definition may change, though).

的主要区别在于视图每次插入后更新,使得该数据是准备就绪,只要你查询视图,而使用自定义的查询将有MySQL的每一次计算的一切(有一些缓存,当然)

The main difference is that views are updated after each insertion, such that the data is "ready" whenever you query the view, whereas using your custom query will have MySQL compute everything each time (there is some caching, of course).

底线是,如果你的名单少frenquently比他们被看作更新,你会看到在性能上有所斩获使用意见。

The bottom line is that if your lists are updated less frenquently than they are viewed, you will see some gains in performance in using views.

这篇关于Mysql的VIEWS与PHP查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆