简体   繁体   English

选择查询的单个功能在项目中其执行或加载时间是快还是慢

[英]A single function for select query in a project its execution or loading time is fast or slow

I am working on codeigniter project. 我正在从事Codeigniter项目。

  1. I am making a "common_model" php page in codeignite project-->application->models and using a method(getSingleRow) for select only a row from tables(any table just like student, users,admin,employee). 我在codeignite项目->应用程序->模型中制作了一个“ common_model” php页面,并使用方法(getSingleRow)从表(任何表,如学生,用户,管理员,雇员)中仅选择一行。 ex. 恩。

     public function getSingleRow($table_name,$where){ $this->db->where($where); $query = $this->db->get($table_name); return $query->row(); } $where is using for columns where condition data. 
  2. I have second project=>student,users,admin,employee section in my project. 我的项目中有第二个项目=>学生,用户,管理员,员工部分。 every section i am making different model page and different method for select query. 我在每个部分都制作了不同的模型页面和不同的选择查询方法。 ex. 恩。 For student application->models->student_model php page and method is this. 对于学生申请->模型-> student_model php页面和方法是这样的。

     public function getStudentSingleRow($where){ $this->db->where($where); $query = $this->db->get('student_table'); return $query->row(); } 

and just like using for all section(admin,users,employee) for model page and method. 就像用于模型页面和方法的所有部分(管理员,用户,员工)一样。

My question is which coding functionality is working faster first(1) or second(2)? 我的问题是,哪种编码功能在first(1)或second(2)上运行更快?

if i have 1100k users 50k employees and 100k students in different tables and more tables. 如果我有1100k用户,则在不同的表和更多表中有5万名员工和10万名学生。 i am using mysql server. 我正在使用mysql服务器。

The only difference is the marginally small amount of memory you use when passing and storing the variable table_name otherwise the two are functionally and speed wise the same. 唯一的区别是在传递和存储变量table_name时使用的内存量很小,否则两者在功能和速度上都是相同的。

Also $this->db->where->($where); 还有$this->db->where->($where); should be $this->db->where($where); 应该是$this->db->where($where); .

As a matter of course I would stray away from the first approach as it is less maintainable is a specific table schema changes. 当然,我会偏离第一种方法,因为特定的表架构更改难以维护。 Better to introduce a model for each student , admin , .etc. 最好为每个studentadmin等介绍一个模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM