<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mark Redding</title>
    <description>The latest articles on DEV Community by Mark Redding (@mark_redding_fb1c365503df).</description>
    <link>https://dev.to/mark_redding_fb1c365503df</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3656365%2F97504012-7c2c-49ee-a670-c0b6dca44695.jpg</url>
      <title>DEV Community: Mark Redding</title>
      <link>https://dev.to/mark_redding_fb1c365503df</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mark_redding_fb1c365503df"/>
    <language>en</language>
    <item>
      <title>5 Database Query Optimization Tips That Actually Work</title>
      <dc:creator>Mark Redding</dc:creator>
      <pubDate>Thu, 11 Dec 2025 01:55:03 +0000</pubDate>
      <link>https://dev.to/mark_redding_fb1c365503df/5-database-query-optimization-tips-that-actually-work-16kh</link>
      <guid>https://dev.to/mark_redding_fb1c365503df/5-database-query-optimization-tips-that-actually-work-16kh</guid>
      <description>&lt;p&gt;After years of managing database-driven applications, I've learned that query optimization can make or break your application's performance. Here are five practical tips I use regularly.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Index Your Foreign Keys
&lt;/h2&gt;

&lt;p&gt;This seems obvious, but it's often overlooked. Every foreign key should have an index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_user_id&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without proper indexing, JOIN operations become painfully slow as your tables grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Use EXPLAIN to Understand Your Queries
&lt;/h2&gt;

&lt;p&gt;Before optimizing, understand what's happening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;category_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table scans (bad)&lt;/li&gt;
&lt;li&gt;Index usage (good)&lt;/li&gt;
&lt;li&gt;Rows examined vs. returned&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Avoid SELECT * in Production
&lt;/h2&gt;

&lt;p&gt;Only fetch the columns you need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Bad&lt;/span&gt;
&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM users"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Good&lt;/span&gt;
&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT id, name, email FROM users"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduces memory usage and network transfer, especially with large tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Use Connection Pooling
&lt;/h2&gt;

&lt;p&gt;Opening database connections is expensive. Reuse them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Use persistent connections in PHP&lt;/span&gt;
&lt;span class="nv"&gt;$pdo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PDO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$dsn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$pass&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="no"&gt;PDO&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;ATTR_PERSISTENT&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Batch Your Inserts
&lt;/h2&gt;

&lt;p&gt;Instead of individual inserts, batch them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Instead of this&lt;/span&gt;
&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$items&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Do this&lt;/span&gt;
&lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;insertBatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$items&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can speed up bulk operations by 10-100x.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Monitor Slow Queries
&lt;/h2&gt;

&lt;p&gt;Enable MySQL's slow query log to catch performance issues:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;GLOBAL&lt;/span&gt; &lt;span class="n"&gt;slow_query_log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ON'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;GLOBAL&lt;/span&gt; &lt;span class="n"&gt;long_query_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any query taking over 2 seconds will be logged for analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Database optimization is an ongoing process. Start with these fundamentals, measure your results, and iterate. Your users will thank you for the faster response times!&lt;/p&gt;

&lt;p&gt;What's your go-to database optimization technique? Share in the comments!&lt;/p&gt;

</description>
      <category>database</category>
      <category>php</category>
      <category>mysql</category>
      <category>performance</category>
    </item>
    <item>
      <title>Accelerating PHP Development with Cursor AI</title>
      <dc:creator>Mark Redding</dc:creator>
      <pubDate>Thu, 11 Dec 2025 01:53:26 +0000</pubDate>
      <link>https://dev.to/mark_redding_fb1c365503df/accelerating-php-development-with-cursor-ai-ln1</link>
      <guid>https://dev.to/mark_redding_fb1c365503df/accelerating-php-development-with-cursor-ai-ln1</guid>
      <description>&lt;p&gt;As a manager overseeing projects at Best Name Badges, I've recently been exploring how AI-powered development tools can streamline our PHP workflows. Cursor AI has been a game-changer for our team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cursor for PHP?
&lt;/h2&gt;

&lt;p&gt;Cursor brings intelligent code completion and AI assistance directly into your development environment. For PHP developers, this means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Context-aware suggestions&lt;/strong&gt;: The AI understands your codebase and suggests relevant functions, classes, and patterns&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster debugging&lt;/strong&gt;: Ask the AI to explain error messages or suggest fixes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code refactoring&lt;/strong&gt;: Get instant suggestions for improving code quality and structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation help&lt;/strong&gt;: Generate PHPDoc blocks automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real-World Impact
&lt;/h2&gt;

&lt;p&gt;At &lt;a href="https://www.bestnamebadges.com" rel="noopener noreferrer"&gt;Best Name Badges&lt;/a&gt;, we manage custom ordering systems and inventory tracking in PHP. Using Cursor has cut our development time significantly, especially when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building new API endpoints&lt;/li&gt;
&lt;li&gt;Refactoring legacy code&lt;/li&gt;
&lt;li&gt;Writing unit tests&lt;/li&gt;
&lt;li&gt;Documenting complex functions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Download Cursor from cursor.sh&lt;/li&gt;
&lt;li&gt;Open your PHP project&lt;/li&gt;
&lt;li&gt;Start coding and use Cmd/Ctrl+K to invoke AI assistance&lt;/li&gt;
&lt;li&gt;Ask questions in natural language about your code&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pro Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the AI to generate boilerplate code for controllers and models&lt;/li&gt;
&lt;li&gt;Ask it to explain unfamiliar PHP functions or frameworks&lt;/li&gt;
&lt;li&gt;Let it help with SQL query optimization&lt;/li&gt;
&lt;li&gt;Use it to convert between different coding standards (PSR-12, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The combination of human expertise and AI assistance is powerful. While managing operations and customer projects, having an AI copilot for PHP development has been invaluable.&lt;/p&gt;

&lt;p&gt;What's your experience with AI coding tools? Drop your thoughts in the comments!&lt;/p&gt;

</description>
      <category>php</category>
      <category>cursor</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
