top-think / top-think/think-orm
使用Db::table或者模型查询oracle数据时很慢
Open
Nobody has claimed this yet.
Oracle
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
查询oracle数据库的时候:
使用Db::table或模型查询比较慢,接口查询100条记录并返回数据要4秒,不知道是为什么,使用原生查询就很快(毫秒级返回数据)
Db::table('lbd_customer')->where('rownum', '<=',100)->select();
但是查看SQL日志中的运行时间又是正常的:
[2021-10-22T17:48:26+08:00][sql] CONNECT:[ UseTime:0.300734s ] oci:dbname=//131.5.91.112:1521/orcl;charset=utf8
[2021-10-22T17:48:26+08:00][sql] select a.column_name,data_type,DECODE (nullable, 'Y', 0, 1) notnull,data_default, DECODE (A .column_name,b.column_name,1,0) pk from all_tab_columns a,(select column_name from all_constraints c, all_cons_columns col where c.constraint_name = col.constraint_name and c.constraint_type = 'P' and c.table_name = 'LBD_CUSTOMER' ) b where table_name = 'LBD_CUSTOMER' and a.column_name = b.column_name (+) [ RunTime:0.036455s ]
[2021-10-22T17:48:26+08:00][sql] SELECT * FROM (SELECT thinkphp.*, rownum AS numrow FROM (SELECT * FROM lbd_customer WHERE rownum <= '100') thinkphp ) [ RunTime:0.038436s ]
使用原生方式查询就很快:
Db::query("select * from lbd_customer where rownum<=:n", ['n' => 100]);
求大佬指点
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by reproducing the difference between Db::table/model queries and Db::query against Oracle, then compare the ORM path with the SQL log shown in the issue. Done means identifying the cause of the delay and providing a verified fix or explanation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sql
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100