Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 PyMySQL 执行一个非常简单的查询:
SELECT `id` FROM `records` ORDER BY `id` DESC
records其中有超过 150 万行。id是主键。
records
id
这是 PyMySQL 的限制吗?如果我一次查询这么多行,还有什么我应该使用的吗?
您可以将查询分解为几个较小的查询:
from math import ceil batch_size = 1000 for start_at in range(int(ceil(total_rows / 1000 * 1.0))): sql = 'SELECT `id` from `RECORDS` ORDER BY `id` DESC LIMIT %i, %i' sql = sql % (start_at * batch_size, batch_size) # fetch rows
当我开始学习 php 时,我了解到当我想调用 php 时,我需要将 php 代码放在这段代码之间,<?php ?>但我也看到了这一点,<? ?>所以我坚持使用第二个选项。
<?php ?>
<? ?>
它们两者之间有什么区别吗,因为最近我看到在一台机器上,第二个选项不起作用,而第一个选项起作用,这让我很困惑。