mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
major speed boost for Oracle :D This took a while, every call to sql_query_limit() was checked out for having any implicit/explicit column issues... Hopefully, nothing has changed :D git-svn-id: file:///svn/phpbb/trunk@6631 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
6cb0276788
commit
1551f13bb2
4 changed files with 4 additions and 50 deletions
|
@ -219,52 +219,6 @@ class dbal_oracle extends dbal
|
||||||
{
|
{
|
||||||
$this->query_result = false;
|
$this->query_result = false;
|
||||||
|
|
||||||
// Any implicit columns exist?
|
|
||||||
if (strpos($query, '.*') !== false)
|
|
||||||
{
|
|
||||||
// This sucker does a few things for us. It grabs all the explicitly named columns and what tables are being used
|
|
||||||
preg_match('/SELECT (?:DISTINCT )?(.*?)FROM(.*?)(?:WHERE|(ORDER|GROUP) BY|$)/s', $query, $tables);
|
|
||||||
|
|
||||||
// The prefixes of the explicit columns don't matter, they simply get in the way
|
|
||||||
preg_match_all('/\.(\w+)/', trim($tables[1]), $columns);
|
|
||||||
|
|
||||||
// Flip lets us do an easy isset() call
|
|
||||||
$columns = array_flip($columns[1]);
|
|
||||||
|
|
||||||
$table_data = trim($tables[2]);
|
|
||||||
|
|
||||||
// Grab the implicitly named columns, they need expanding...
|
|
||||||
preg_match_all('/(\w)\.\*/', $query, $info);
|
|
||||||
|
|
||||||
$cols = array();
|
|
||||||
|
|
||||||
foreach ($info[1] as $table_alias)
|
|
||||||
{
|
|
||||||
// We need to get the name of the aliased table
|
|
||||||
preg_match('/(\w+) ' . $table_alias . '/', $table_data, $table_name);
|
|
||||||
$table_name = $table_name[1];
|
|
||||||
|
|
||||||
$sql = "SELECT column_name
|
|
||||||
FROM all_tab_cols
|
|
||||||
WHERE table_name = '" . strtoupper($table_name) . "'";
|
|
||||||
|
|
||||||
$result = $this->sql_query($sql);
|
|
||||||
while ($row = $this->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
if (!isset($columns[strtolower($row['column_name'])]))
|
|
||||||
{
|
|
||||||
$cols[] = $table_alias . '.' . strtolower($row['column_name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->sql_freeresult($result);
|
|
||||||
|
|
||||||
// Remove the implicity .* with it's full expansion
|
|
||||||
$query = str_replace($table_alias . '.*', implode(', ', $cols), $query);
|
|
||||||
|
|
||||||
unset($cols);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset;
|
$query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset;
|
||||||
|
|
||||||
return $this->sql_query($query, $cache_ttl);
|
return $this->sql_query($query, $cache_ttl);
|
||||||
|
|
|
@ -134,7 +134,7 @@ function mcp_front_view($id, $mode, $action)
|
||||||
$global_id = $forum_list[0];
|
$global_id = $forum_list[0];
|
||||||
|
|
||||||
$sql = $db->sql_build_query('SELECT', array(
|
$sql = $db->sql_build_query('SELECT', array(
|
||||||
'SELECT' => 'r.*, p.post_id, p.post_subject, u.username, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
|
'SELECT' => 'r.report_time, p.post_id, p.post_subject, u.username, u.user_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
|
||||||
|
|
||||||
'FROM' => array(
|
'FROM' => array(
|
||||||
REPORTS_TABLE => 'r',
|
REPORTS_TABLE => 'r',
|
||||||
|
|
|
@ -131,7 +131,7 @@ function compose_pm($id, $mode, $action)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT t.*, p.*, u.username as quote_username
|
$sql = 'SELECT t.folder_id, p.*, u.username as quote_username
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
|
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||||
WHERE t.user_id = ' . $user->data['user_id'] . "
|
WHERE t.user_id = ' . $user->data['user_id'] . "
|
||||||
AND p.author_id = u.user_id
|
AND p.author_id = u.user_id
|
||||||
|
@ -147,7 +147,7 @@ function compose_pm($id, $mode, $action)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for outbox (not read) status, we do not allow editing if one user already having the message
|
// check for outbox (not read) status, we do not allow editing if one user already having the message
|
||||||
$sql = 'SELECT p.*, t.*
|
$sql = 'SELECT p.*, t.folder_id
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
|
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
|
||||||
WHERE t.user_id = ' . $user->data['user_id'] . '
|
WHERE t.user_id = ' . $user->data['user_id'] . '
|
||||||
AND t.folder_id = ' . PRIVMSGS_OUTBOX . "
|
AND t.folder_id = ' . PRIVMSGS_OUTBOX . "
|
||||||
|
|
|
@ -519,7 +519,7 @@ function get_pm_from($folder_id, $folder, $user_id)
|
||||||
$sql_start = $start;
|
$sql_start = $start;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT t.*, p.author_id, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.user_colour
|
$sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.user_colour
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
|
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
|
||||||
WHERE t.user_id = $user_id
|
WHERE t.user_id = $user_id
|
||||||
AND p.author_id = u.user_id
|
AND p.author_id = u.user_id
|
||||||
|
|
Loading…
Add table
Reference in a new issue