<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tiffany B. Brown &#187; NYPHPCon2006</title>
	<atom:link href="http://tiffanybbrown.com/category/events/nyphpcon2006/feed/" rel="self" type="application/rss+xml" />
	<link>http://tiffanybbrown.com</link>
	<description>A web log about web development and internet culture with frequent detours into other stuff.</description>
	<lastBuildDate>Fri, 10 Feb 2012 23:35:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>NYPHPCon 2006 speaker presentations now available</title>
		<link>http://tiffanybbrown.com/2006/06/28/nyphpcon-2006-speaker-presentations-now-available/</link>
		<comments>http://tiffanybbrown.com/2006/06/28/nyphpcon-2006-speaker-presentations-now-available/#comments</comments>
		<pubDate>Wed, 28 Jun 2006 13:08:46 +0000</pubDate>
		<dc:creator>tiffany</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[NYPHPCon2006]]></category>

		<guid isPermaLink="false">http://tiffanybbrown.com/viewqb.php/673</guid>
		<description><![CDATA[Most of them are in, and they&#8217;re available on the NYPHPCon web site. And if you missed it, I also posted some notes from the conference.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nyphpcon.com"><img border="0" alt="New York PHP Conference and Expo 2006" title="New York PHP Conference and Expo 2006" src="http://www.nyphpcon.com/images/NYPHPConLinkableLogo.jpg" style="float:right;margin:10px;" /></a></p>
<p>Most of them are in, and they&#8217;re <a href="http://www.nyphpcon.com/speakers.php">available</a> on the NYPHPCon web site.</p>
<p>And if you missed it, I also <a href="http://tiffanybbrown.com/viewqb.php/category/events/nyphpcon2006/">posted some notes</a> from the conference.</p>
]]></content:encoded>
			<wfw:commentRss>http://tiffanybbrown.com/2006/06/28/nyphpcon-2006-speaker-presentations-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NYPHP Con: &#8220;Introduction to PDO&#8221;</title>
		<link>http://tiffanybbrown.com/2006/06/16/nyphp-con-introduction-to-pdo/</link>
		<comments>http://tiffanybbrown.com/2006/06/16/nyphp-con-introduction-to-pdo/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 11:00:17 +0000</pubDate>
		<dc:creator>tiffany</dc:creator>
				<category><![CDATA[MySQL / Databases]]></category>
		<category><![CDATA[NYPHPCon2006]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development & Programming]]></category>

		<guid isPermaLink="false">http://tiffanybbrown.com/viewqb.php/651</guid>
		<description><![CDATA[PDO ships with PHP 5.1. You do not need to install via PECL These are my notes from a presentation by Ilia Alshanetsky. This post may contain inaccuracies, typos, boo-boos, etc. PDO stands for &#8220;PHP Data Objects Layer&#8221;: A data-access abstraction layer. Common interface for any number of database systems PHP extension Designed to simplify [...]]]></description>
			<content:encoded><![CDATA[<p class="editors-note"><a href="http://php.net/pdo">PDO</a> ships with PHP 5.1. You do not need to install via PECL</p>
<p class="editors-note">These are my notes from a presentation by <a href="http://ilia.ws/">Ilia Alshanetsky</a>. This post may contain inaccuracies, typos, boo-boos, etc.</p>
<p>PDO stands for &#8220;PHP Data Objects Layer&#8221;: A data-access abstraction layer.</p>
<ul>
<li>Common interface for any number of database systems</li>
<li>PHP extension</li>
<li>Designed to simplify features. </li>
<li>Only available to PHP 5 or 5.1; requires a level of OOPHP that&#8217;s only available to PHP 5</li>
</ul>
<h3>Why PDO?</h3>
<ul>
<li>Consistency of development across databases; code is the same for MySQL, PostgreSQL, Oracle, etc.</li>
<li>Current APIs don&#8217;t take full advantage of new PHP&#8217;s features</li>
<li>Current APIs don&#8217;t take full advantage of all of the features available in the database </li>
</ul>
<h3>Installation</h3>
<ul>
<li>Need to install PDO, made up of the core and the drivers. </li>
<li>Can install using PECL. </li>
<li>Can install by recompiling PHP</li>
</ul>
<h3>Using PDO</h3>
<ul>
<li>Create an instance of the object.</li>
<li>PDO uses a single connection string as the lone parameter.
<ul>
<li>Connection failure handling: Instantiation failure causes an exception error. Use inside of a try&#8230;catch block to retrieve and log the error number.</li>
<li>Functions available to report errors</li>
</ul>
</li>
</ul>
<h4>Persistent Connections</h4>
<ul>
<li>Persistent connections help speed up web apps, particularly with Oracle and PostgreSQL databases</li>
<li>Create persistent connections using a class constant ATTR_PERSISTENT</li>
<li>Will need to figure out how many connections you will have at one time (MySQL makes quick connections. Don&#8217;t really need to make a persistent one, but likely won&#8217;t hurt)</li>
</ul>
<h3>Direct Query Execution using PDO</h3>
<ul>
<li>Queries that modify information use the exec() method. </li>
<li>Return value is the number of rows affected by the operation. Returns boolean FALSE on error (INSERT, UPDATE, DELETE). </li>
<li>Queries that select information use the query() method.</li>
</ul>
<h4>Problems with direct queries</h4>
<ul>
<li>Query needs to be interpreted on each execution. Can be a waste for frequently repeated queries. </li>
<li>Security issues with un-escaped user input can lead to SQL injection.</li>
<li>Escaping: quote() method. Handles special characters in PDO. Quote automatically adds single quotes to wrap the query: <code>"SELECT * FROM USERS WHERE".quote($variable)." LIMIT 0,1"</code></li>
</ul>
<h3>Prepared statements</h3>
<ul>
<li>Compile once and execute many times</li>
<li>Separation between structure and input to prevents SQL injections</li>
<li>Often faster than query()/exec() even for single runs.</li>
<li>Uses wildcards/tokens to hold variables; those variables are handled as a parameter, making injection attacks much less likely (bound parameters)</li>
</ul>
<h3>Retrieving information using PDO</h3>
<ul>
<li>Array (Numeric or associative)</li>
<li>String (for single column result sets; ex: selecting an id from a user login table)</li>
<li>Fetch into a class</li>
<li>Objects
<ul>
<li>Ability to retrieve data into an object</li>
<li>Ability to retrieve data into an exisiting object</li>
</ul>
</li>
<li>Callback Function</li>
<li>Lazy fetching</li>
<li>Iterators</li>
</ul>
<h4>Result Iteration &#8211; Fastest way of retrieving data through PDO</h4>
<pre>
$res=$db->query("select * from users",PDO::FETCH_ASSOC);
foreach($res as $row){
   // returns an associated array
}
</pre>
<h4>Lazy fetches</h4>
<ul>
<li>Lazy fetches results in a form object, but holds the populating properties until they are actually used.</li>
<li>Prevents PHP from fetching the data until you use it.</li>
</ul>
<h3>Related links</h3>
<ul>
<li><a href="http://us3.php.net/manual/en/ref.pdo.php">PDO Functions</a></li>
<li><a href="http://www.zend.com/php5/articles/php5-mysqli.php#Heading10">Prepared Statements and Bound Parameters</a> (from an article about using ext/mysqli)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tiffanybbrown.com/2006/06/16/nyphp-con-introduction-to-pdo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>NYPHP Con: &#8220;Maximum Velocity MySQL&#8221; &#8211; Benchmarking and Profiling</title>
		<link>http://tiffanybbrown.com/2006/06/14/mysql-benchmarking-profiling/</link>
		<comments>http://tiffanybbrown.com/2006/06/14/mysql-benchmarking-profiling/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 02:12:13 +0000</pubDate>
		<dc:creator>tiffany</dc:creator>
				<category><![CDATA[MySQL / Databases]]></category>
		<category><![CDATA[NYPHPCon2006]]></category>

		<guid isPermaLink="false">http://tiffanybbrown.com/viewqb.php/647</guid>
		<description><![CDATA[Jay Pipes is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. This is part three of my notes. This post may contain inaccuracies, typos, boo-boos, etc. Jay says his slides will be available on his web site, so be sure to check [...]]]></description>
			<content:encoded><![CDATA[<p class="editors-note"><a href="http://jpipes.com/">Jay Pipes</a> is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. </p>
<p class="editors-note">This is part three of my notes. This post may contain inaccuracies, typos, boo-boos, etc. Jay says his slides will be available <a href="http://jpipes.com/">on his web site</a>, so be sure to check there as well. If you have questions, direct them to Jay or consult the <a href="http://dev.mysql.com/">MySQL documentation</a>.</p>
<h3>Benchmarking and Profiling tips</h3>
<ul>
<li>Give yourself a target</li>
<li>Record everything</li>
<li>Isolate the problem (Shut down other programs. Stop network traffic to machine.)</li>
<li>Get familiar with <a href="http://dev.mysql.com/doc/refman/4.1/en/explain.html">EXPLAIN</a> as a means to optimize queries</li>
<li>Optimize within reason. Makes more sense to speed up the 30 second query than the 1 second query.</li>
</ul>
<h3>Benchmarking Toolbox</h3>
<ul>
<li><a href="http://sysbench.sourceforge.net/">SysBench</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html">mysqlslap (MySQL version 5.1+)</a></li>
<li><a href="http://httpd.apache.org/docs/1.3/programs/ab.html">Apache bench</a></li>
<li><a href="http://www.vegan.net/tony/supersmack/">Supersmack</a></li>
<li><a href="http://jeremy.zawodny.com/mysql/mybench">MyBench</a></li>
</ul>
<h3>Profiling: Diagnosing a running system to identify performance bottlenecks</h3>
<p>Possible areas for bottlenecks: </p>
<ul>
<li>Identify performance bottlenecks</li>
<li>SQL Coding and Index Usage</li>
<li>Memory</li>
<li>CPU</li>
<li>I/O (Disk)</li>
</ul>
<p> Profiling toolbox</p>
<ul>
<li><a href="http://dev.mysql.com/show/">SHOW commands (SHOW PROCESSLIST, etc&#8230;)</a></li>
<li><a href="http://dev.mysql.com/explain/">EXPLAIN and the Slow Query Log</a></li>
<li><a href="http://jeremy.zawodny.com/mysql/mytop">MyTop</a></li>
<li>List of Linux Power tools (gprof/oprofile and vmstat.ps/top/mpstat/procinfo)</li>
<li><a href="http://pecl.php.net/package/apd/">apd for PHP developers</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tiffanybbrown.com/2006/06/14/mysql-benchmarking-profiling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NYPHP Con: &#8220;Maximum Velocity MySQL&#8221; &#8211; Optimization and coding tips</title>
		<link>http://tiffanybbrown.com/2006/06/14/mysql-optimization-and-coding-tips/</link>
		<comments>http://tiffanybbrown.com/2006/06/14/mysql-optimization-and-coding-tips/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 01:38:23 +0000</pubDate>
		<dc:creator>tiffany</dc:creator>
				<category><![CDATA[MySQL / Databases]]></category>
		<category><![CDATA[NYPHPCon2006]]></category>

		<guid isPermaLink="false">http://tiffanybbrown.com/viewqb.php/646</guid>
		<description><![CDATA[With Jay Pipes of MySQL. Jay Pipes is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. This is part two of my notes. This post may contain inaccuracies, typos, boo-boos, etc. Jay says his slides will be available on his web site, [...]]]></description>
			<content:encoded><![CDATA[<p>With Jay Pipes of MySQL.  </p>
<p class="editors-note"><a href="http://jpipes.com/">Jay Pipes</a> is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. </p>
<p class="editors-note">This is part two of my notes. This post may contain inaccuracies, typos, boo-boos, etc. Jay says his slides will be available <a href="http://jpipes.com/">on his web site</a>, so be sure to check there as well. If you have questions, direct them to Jay or consult the <a href="http://dev.mysql.com/">MySQL documentation</a>.</p>
<h3>Developing a database schema</h3>
<ul>
<li>Use the smallest data type necessary</li>
<li><a href="http://en.wikipedia.org/wiki/Database_normalization">Normalize</a> your data; Denormalize only in extreme cases</li>
<li>&#8220;Vertical partitioning&#8221;: Send to a different database based on the range of a key.</li>
<li>Use &#8216;counter tables&#8217; to mitigate query cache issues in InnoDB tables</li>
<li>&#8220;Horizontal partitioning&#8221;: Split data into smaller tables. Put less-frequently accessed, less-frequently updated data in a separate table. Example: have separate tables for user logins and user addresses or interests.</li>
</ul>
<h3>Use indexes wisely</h3>
<ul>
<li>Should have good selectivity (relative uniqueness of the index values to each other; there&#8217;s a way to calculate this)</li>
<li>Look for &#8216;covering index&#8217; opportunities</li>
<li>On multi-column indexes, order is important</li>
<li>As database grows, examine your index. Do you need to modify it?</li>
<li>Remove redundant indexes for faster write performance. Don&#8217;t need more than one index on a field.</li>
</ul>
<h3>Coding tips</h3>
<ul>
<li>Don&#8217;t think in a procedural programming style. Think about &#8216;sets&#8217;: you have two sets of data from which you need to retrieve data. How do you do this?</li>
<li>Break queries into smaller units</li>
<li>Use stored procedures (only available in MySQL 5.x)</li>
<li>Learn to use <a href="http://dev.mysql.com/doc/refman/4.1/en/join.html" title="More about JOIN syntax in the My S Q L documentation">JOINS</a> effectively. Can often use a join instead of a subquery.</li>
<li>When you use a function on an indexed function, the index will be ignored</li>
<li>Use the ON DUPLICATE KEY UPDATE clause of the insert statement. No need to check first if the record exists then update or delete (Related: <a href="http://www.mysqlperformanceblog.com/2006/05/29/insert-on-duplicate-key-update-and-summary-counters/">INSERT ON DUPLICATE KEY UPDATE and summary counters</a>)</li>
<li>TRUNCATE TABLE is typically faster than deleting records</li>
</ul>
<h3>Bulk loading performance</h3>
<ul>
<li>Always use multi-record INSERT for mass bulk uploading</li>
<li>Use ALTER TABLE &#8230; DISABLE KEYS syntax. It disables all indexes except for unique ones</li>
<li>Use load data infile, or CSV storage engine (version 5.x only), then ALTER TABLE</li>
<li>If loading into an InnoDB table, insert into a MyISAM table, then select from there into an InnoDB table</li>
<li>To add or drop multiple indexes, use ALTER TABLE rather than multiple CREATE or DROP INDEX statements</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tiffanybbrown.com/2006/06/14/mysql-optimization-and-coding-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NYPHP Con: &#8220;Maximum Velocity MySQL&#8221; &#8211; Indexes and storage engines</title>
		<link>http://tiffanybbrown.com/2006/06/14/mysql-indexes-storage-engines/</link>
		<comments>http://tiffanybbrown.com/2006/06/14/mysql-indexes-storage-engines/#comments</comments>
		<pubDate>Wed, 14 Jun 2006 16:04:00 +0000</pubDate>
		<dc:creator>tiffany</dc:creator>
				<category><![CDATA[MySQL / Databases]]></category>
		<category><![CDATA[NYPHPCon2006]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://tiffanybbrown.com/viewqb.php/645</guid>
		<description><![CDATA[With Jay Pipes of MySQL. Diversity stats, in case you&#8217;re wondering: Men: about 30. Women: 4. People of color: 4. Jay Pipes is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. This is part one of my notes. This post may contain [...]]]></description>
			<content:encoded><![CDATA[<p>With Jay Pipes of MySQL. Diversity stats, in case you&#8217;re wondering: Men: about 30. Women: 4. People of color: 4.</p>
<p class="editors-note"><a href="http://jpipes.com/">Jay Pipes</a> is the Community Relations Manager, North America for MySQL, Inc. This was a three-hour tutorial about ways to fine-tune your MySQL queries. </p>
<p class="editors-note">This is part one of my notes. This post may contain inaccuracies, typos, boo-boos, etc. Jay says his slides will be available <a href="http://jpipes.com/">on his web site</a>, so be sure to check there as well. If you have questions, direct them to Jay or consult the <a href="http://dev.mysql.com/">MySQL documentation</a>.</p>
<h3>Indexes</h3>
<ul>
<li>Gives you a sorted order that allows you to find things quickly. </li>
<li>Indexes speed up select or read statements. </li>
<li>Indexes slow down writing to the database because MySQL not only has to write the record, but also has to write the index.</li>
</ul>
<p>The kind of indexes available and their efficiency depends on the type of storage engine you choose. Keep your indexes slim on write-intensive applications.</p>
<h3>Types of storage engines</h3>
<p>Choose your table&#8217;s storage engine type based on the type of information it holds, and the function for which you will use the table. Can mix table types in the same database.</p>
<h4>MyISAM</h4>
<ul>
<li>Unclustered data storage</li>
<li>Good insert performance and good with concurrent inserts</li>
<li>Small foot print</li>
<li>B-tree, r-tree and FULLTEXT indexing; Can use for spatial calculations, such as ZIP codes</li>
<li>Poor concurrent update and delete performance</li>
<li>No foreign key support; You can use a foreign key, but relational integrity is not guaranteed. (Forthcoming in version 5.2)</li>
<li>No transactions available</li>
</ul>
<p>Good for warehousing data, logging data and auditing data. </p>
<h4>InnoDB</h4>
<p>Good for when you need a lot of concurrent updates and will be looking data up by ID. Good for online transaction processing.</p>
<ul>
<li>NO FULLTEXT indexing or spacial data (r-tree indexes). </li>
<li>Large memory usage and a large data footprint.</li>
<li>Full transactional support</li>
<li>Support for foreign keys</li>
<li>Be sure to set a primary key, and use the smallest possible key (INT not BIGINT). If you don&#8217;t InnoDB will create it&#8217;s own super-integer index. Because of the way InnoDB handles indexes, this <em>is not</em> desirable. </li>
</ul>
<h4>Archive</h4>
<p>Good for archiving, audit logging, and distributable media (for example, applications that you don&#8217;t want the user to be able to modify).</p>
<ul>
<li>Quick inserts and table scans</li>
<li>Read-only</li>
<li>Zlib compression</li>
<li>No indexes allowed</li>
<li>No foreign key support</li>
</ul>
<h4>Memory / HEAP</h4>
<p>Great for temporary tables, session data, calculation tables, or information that will be requested frequently.</p>
<ul>
<li>Very, very fast selects because it&#8217;s all stored in memory</li>
<li>Supports hash or b-tree indexes</li>
<li>Data is gone on reboot, but you can get around this with <code>init_file</code> or my.cnf/my.ini.</li>
<li>Limited by amount of memory available on the server</li>
</ul>
<p>Can combine engine types within the database to take advantage of each storage engine&#8217;s strengths.</p>
]]></content:encoded>
			<wfw:commentRss>http://tiffanybbrown.com/2006/06/14/mysql-indexes-storage-engines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

