diff options
| author | fisharebest <fisharebest@gmail.com> | 2011-09-14 21:39:00 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2011-09-14 21:39:00 +0000 |
| commit | 99cadd490e2af606e02c95107245cd7928c5a8fe (patch) | |
| tree | 56d42d318b59d5021eb1c53eeb70f252158c8519 | |
| parent | 560f434f0194c503cd9f973fa493854e62b65425 (diff) | |
| download | webtrees-99cadd490e2af606e02c95107245cd7928c5a8fe.tar.gz webtrees-99cadd490e2af606e02c95107245cd7928c5a8fe.tar.bz2 webtrees-99cadd490e2af606e02c95107245cd7928c5a8fe.zip | |
Performance - it is faster to extract the sex from the gedcom record than it is to fetch the i_sex column from the database
| -rw-r--r-- | autocomplete.php | 8 | ||||
| -rw-r--r-- | includes/functions/functions_db.php | 50 | ||||
| -rw-r--r-- | includes/functions/functions_export.php | 2 | ||||
| -rw-r--r-- | library/WT/Controller/AdvancedSearch.php | 2 | ||||
| -rw-r--r-- | library/WT/Person.php | 12 | ||||
| -rw-r--r-- | library/WT/Query/Name.php | 2 | ||||
| -rw-r--r-- | modules_v3/descendancy/module.php | 2 | ||||
| -rw-r--r-- | modules_v3/families/module.php | 2 | ||||
| -rw-r--r-- | modules_v3/individuals/module.php | 2 |
9 files changed, 23 insertions, 59 deletions
diff --git a/autocomplete.php b/autocomplete.php index e3772a714f..01e3376e1b 100644 --- a/autocomplete.php +++ b/autocomplete.php @@ -545,7 +545,7 @@ function get_autocomplete_INDI($FILTER, $ged_id=WT_GED_ID) { // search for ids first and request the exact id from FILTER and ids with one additional digit $rows= WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`, `##name`". " WHERE (i_id=? OR i_id LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". @@ -558,7 +558,7 @@ function get_autocomplete_INDI($FILTER, $ged_id=WT_GED_ID) { if (count($rows)==0) { return WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`, `##name`". " WHERE n_sort LIKE ?". " AND i_id=n_id AND i_file=n_file AND i_file=?". @@ -635,7 +635,7 @@ function get_autocomplete_SOUR_TITL($FILTER, $ged_id=WT_GED_ID) { function get_autocomplete_INDI_BURI_CEME($FILTER, $ged_id=WT_GED_ID) { return WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`". " WHERE i_gedcom LIKE ? AND i_file=?". " LIMIT ".WT_AUTOCOMPLETE_LIMIT @@ -647,7 +647,7 @@ function get_autocomplete_INDI_BURI_CEME($FILTER, $ged_id=WT_GED_ID) { function get_autocomplete_INDI_SOUR_PAGE($FILTER, $OPTION, $ged_id=WT_GED_ID) { return WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`". " WHERE i_gedcom LIKE ? AND i_file=?". " LIMIT ".WT_AUTOCOMPLETE_LIMIT diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index 5eac97ef31..ab06a5dc05 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -78,7 +78,7 @@ function count_linked_obje($xref, $link, $ged_id) { //////////////////////////////////////////////////////////////////////////////// function fetch_linked_indi($xref, $link, $ged_id) { $rows=WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`". " JOIN `##link` ON (i_file=l_file AND i_id=l_from)". " LEFT JOIN `##name` ON (i_file=n_file AND i_id=n_id AND n_num=0)". @@ -195,7 +195,7 @@ function fetch_person_record($xref, $ged_id) { if (is_null($statement)) { $statement=WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex ". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec ". "FROM `##individuals` WHERE i_id=? AND i_file=?" ); } @@ -284,13 +284,7 @@ function fetch_gedcom_record($xref, $ged_id) { } } -/** -* find the gedcom record for a family -* -* @link http://phpgedview.sourceforge.net/devdocs/arrays.php#family -* @param string $famid the unique gedcom xref id of the family record to retrieve -* @return string the raw gedcom record is returned -*/ +// find the gedcom record for a family function find_family_record($xref, $ged_id) { static $statement=null; @@ -302,13 +296,7 @@ function find_family_record($xref, $ged_id) { return $statement->execute(array($xref, $ged_id))->fetchOne(); } -/** -* find the gedcom record for an individual -* -* @link http://phpgedview.sourceforge.net/devdocs/arrays.php#indi -* @param string $pid the unique gedcom xref id of the individual record to retrieve -* @return string the raw gedcom record is returned -*/ +// find the gedcom record for an individual function find_person_record($xref, $ged_id) { static $statement=null; @@ -320,13 +308,7 @@ function find_person_record($xref, $ged_id) { return $statement->execute(array($xref, $ged_id))->fetchOne(); } -/** -* find the gedcom record for a source -* -* @link http://phpgedview.sourceforge.net/devdocs/arrays.php#source -* @param string $sid the unique gedcom xref id of the source record to retrieve -* @return string the raw gedcom record is returned -*/ +// find the gedcom record for a source function find_source_record($xref, $ged_id) { static $statement=null; @@ -452,13 +434,7 @@ function exists_pending_change($user_id=WT_USER_ID, $ged_id=WT_GED_ID) { } } -/** -* get a list of all the sources -* -* returns an array of all of the sources in the database. -* @link http://phpgedview.sourceforge.net/devdocs/arrays.php#sources -* @return array the array of sources -*/ +// get a list of all the sources function get_source_list($ged_id) { $rows= WT_DB::prepare("SELECT 'SOUR' AS type, s_id AS xref, s_file AS ged_id, s_gedcom AS gedrec FROM `##sources` s WHERE s_file=?") @@ -507,7 +483,7 @@ function get_note_list($ged_id) { // Search for INDIs using custom SQL generated by the report engine function search_indis_custom($join, $where, $order) { - $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex FROM `##individuals` ".implode(' ', $join).' WHERE '.implode(' AND ', $where); + $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec FROM `##individuals` ".implode(' ', $join).' WHERE '.implode(' AND ', $where); if ($order) { $sql.=' ORDER BY '.implode(' ', $order); } @@ -582,7 +558,7 @@ function search_indis($query, $geds, $match, $skip) { $querysql[]="i_gedcom LIKE ".WT_DB::quote("%{$q}%")." COLLATE '".WT_I18N::$collation."'"; } - $sql="SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex FROM `##individuals` WHERE (".implode(" {$match} ", $querysql).') AND i_file IN ('.implode(',', $geds).')'; + $sql="SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec FROM `##individuals` WHERE (".implode(" {$match} ", $querysql).') AND i_file IN ('.implode(',', $geds).')'; // Group results by gedcom, to minimise switching between privacy files $sql.=' ORDER BY ged_id'; @@ -635,7 +611,7 @@ function search_indis_names($query, $geds, $match) { foreach ($query as $q) { $querysql[]="n_full LIKE ".WT_DB::quote("%{$q}%")." COLLATE '".WT_I18N::$collation."'"; } - $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex, n_num FROM `##individuals` JOIN `##name` ON i_id=n_id AND i_file=n_file WHERE (".implode(" {$match} ", $querysql).') AND i_file IN ('.implode(',', $geds).')'; + $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, n_num FROM `##individuals` JOIN `##name` ON i_id=n_id AND i_file=n_file WHERE (".implode(" {$match} ", $querysql).') AND i_file IN ('.implode(',', $geds).')'; // Group results by gedcom, to minimise switching between privacy files $sql.=' ORDER BY ged_id'; @@ -674,7 +650,7 @@ function search_indis_names($query, $geds, $match) { // $lastname, $firstname, $place - search terms // $geds - array of gedcoms to search function search_indis_soundex($soundex, $lastname, $firstname, $place, $geds) { - $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex FROM `##individuals`"; + $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec FROM `##individuals`"; if ($place) { $sql.=" JOIN `##placelinks` ON (pl_file=i_file AND pl_gid=i_id)"; $sql.=" JOIN `##places` ON (p_file=pl_file AND pl_p_id=p_id)"; @@ -762,7 +738,7 @@ function get_recent_changes($jd=0, $allgeds=false) { // Seach for individuals with events on a given day function search_indis_dates($day, $month, $year, $facts) { - $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex FROM `##individuals` JOIN `##dates` ON i_id=d_gid AND i_file=d_file WHERE i_file=?"; + $sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec FROM `##individuals` JOIN `##dates` ON i_id=d_gid AND i_file=d_file WHERE i_file=?"; $vars=array(WT_GED_ID); if ($day) { $sql.=" AND d_day=?"; @@ -800,7 +776,7 @@ function search_indis_dates($day, $month, $year, $facts) { // Seach for individuals with events in a given date range function search_indis_daterange($start, $end, $facts) { - $sql="SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex FROM `##individuals` JOIN `##dates` ON i_id=d_gid AND i_file=d_file WHERE i_file=? AND d_julianday1 BETWEEN ? AND ?"; + $sql="SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec FROM `##individuals` JOIN `##dates` ON i_id=d_gid AND i_file=d_file WHERE i_file=? AND d_julianday1 BETWEEN ? AND ?"; $vars=array(WT_GED_ID, $start, $end); if ($facts) { @@ -1359,7 +1335,7 @@ function get_anniversary_events($jd, $facts='', $ged_id=WT_GED_ID) { $where.=" AND d_file=".$ged_id; // Now fetch these anniversaries - $ind_sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex, d_type, d_day, d_month, d_year, d_fact FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_day ASC, d_year DESC"; + $ind_sql="SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, d_type, d_day, d_month, d_year, d_fact FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_day ASC, d_year DESC"; $fam_sql="SELECT DISTINCT 'FAM' AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_numchil, d_type, d_day, d_month, d_year, d_fact FROM `##dates`, `##families` {$where} AND d_gid=f_id AND d_file=f_file ORDER BY d_day ASC, d_year DESC"; foreach (array($ind_sql, $fam_sql) as $sql) { $rows=WT_DB::prepare($sql)->fetchAll(PDO::FETCH_ASSOC); diff --git a/includes/functions/functions_export.php b/includes/functions/functions_export.php index f5474024d7..2b79d93459 100644 --- a/includes/functions/functions_export.php +++ b/includes/functions/functions_export.php @@ -214,7 +214,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { $buffer=reformat_record_export($head); $rows=WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals` WHERE i_file=? ORDER BY i_id" )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { diff --git a/library/WT/Controller/AdvancedSearch.php b/library/WT/Controller/AdvancedSearch.php index f19348ba8d..7e45ce7b67 100644 --- a/library/WT/Controller/AdvancedSearch.php +++ b/library/WT/Controller/AdvancedSearch.php @@ -182,7 +182,7 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search { $sql = ''; if ($justSql) $sqlfields = "SELECT {$prefix}_id, {$prefix}_file"; - else $sqlfields = "SELECT i_id, i_gedcom, i_file, i_sex"; + else $sqlfields = "SELECT i_id, i_gedcom, i_file"; $sqltables = " FROM `##".$table."`"; $sqlwhere = " WHERE ".$prefix."_file=".WT_GED_ID; $keepfields = $this->fields; diff --git a/library/WT/Person.php b/library/WT/Person.php index c855fea4aa..2e111ae83a 100644 --- a/library/WT/Person.php +++ b/library/WT/Person.php @@ -55,18 +55,6 @@ class WT_Person extends WT_GedcomRecord { private $_getAllDeathPlaces=null; private $_getEstimatedDeathDate=null; - // Create a Person object from either raw GEDCOM data or a database row - function __construct($data) { - if (is_array($data)) { - // Construct from a row from the database - $this->sex =$data['i_sex']; - } else { - // Construct from raw GEDCOM data - } - - parent::__construct($data); - } - // Can the name of this record be shown? public function canDisplayName($access_level=WT_USER_ACCESS_LEVEL) { global $SHOW_LIVING_NAMES; diff --git a/library/WT/Query/Name.php b/library/WT/Query/Name.php index 9088fe8fa4..fb11f83faa 100644 --- a/library/WT/Query/Name.php +++ b/library/WT/Query/Name.php @@ -384,7 +384,7 @@ class WT_Query_Name { // To search for names with no surnames, use $salpha="," public static function individuals($surn, $salpha, $galpha, $marnm, $fams, $ged_id) { $sql= - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex, n_full ". + "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, n_full ". "FROM `##individuals` ". "JOIN `##name` ON (n_id=i_id AND n_file=i_file) ". ($fams ? "JOIN `##link` ON (n_id=l_from AND n_file=l_file AND l_type='FAMS') " : ""). diff --git a/modules_v3/descendancy/module.php b/modules_v3/descendancy/module.php index 5f654a0d07..59f77b3386 100644 --- a/modules_v3/descendancy/module.php +++ b/modules_v3/descendancy/module.php @@ -186,7 +186,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { if (strlen($query)<2) return ''; $rows=WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". diff --git a/modules_v3/families/module.php b/modules_v3/families/module.php index fb81bebd71..cdf7badb9f 100644 --- a/modules_v3/families/module.php +++ b/modules_v3/families/module.php @@ -219,7 +219,7 @@ class families_WT_Module extends WT_Module implements WT_Module_Sidebar { //-- search for INDI names $rows=WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". diff --git a/modules_v3/individuals/module.php b/modules_v3/individuals/module.php index 651963abff..5658d7fb1d 100644 --- a/modules_v3/individuals/module.php +++ b/modules_v3/individuals/module.php @@ -218,7 +218,7 @@ class individuals_WT_Module extends WT_Module implements WT_Module_Sidebar { } $rows= WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_sex". + "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". |
