Faster Retrieval and Array Searching with Laravel

April 15, 2014

The other day I ran into a performance issue when working with a large database table in a Laravel application. The application has an artisan command that parses a large chunk of text data and looks for specific word matches in this large database table before deciding what to do with each particular word match.

Querying this table for every word match that the parser finds would cause me to run into something like the dreaded n+1 problem, where I would be executing a database select on every word that the command encountered. So I decided to load this table into memory and let the command search it without hitting the database.

The table is approximately 300,000 rows, and I'm most interested in one column that is a VARCHAR(255). In most cases the column values are 8-20 bytes only, which would eat up about 6MB of memory. If the table grew significantly, I may have to figure out another solution.

Here is a summary of the various steps I took to accomplish this task, and to improve performance along the way.

Read More|Comments (0)

Examining Laravel Database Queries

March 18, 2014

I've been using Laravel lately for most web projects, which I've been finding to be a pleasure to develop with. Laravel is straighforward, has great documentation, and is well thought out to make development tasks fast and pain-free.

Like any full-featured web framework, Laravel provides an ORM implementation, called Eloquent, which translates objects and their relations to an underlying SQL datasource. For example, a database table called users may relate to a model class called User, which can be queried:

$users = User->all();     // find all users
$user = User->find(123);  // find a user with id 123
$users = User->where('account_type', 'PAID')->get();  // find all paying users

Read More|Comments (0)

Static Site Generation With Sculpin

March 2, 2014

There are many static site generators out there. This post covers setting up a simple static website using the Sculpin static site generator, written in PHP. I found this to be a well-maintained project with easy to follow documentation.

Most dynamic websites are built using a multi-tier architecture. For a relatively simple website it is possible to cut out the data and business-logic layers and serve only static html content. This makes a site more manageable, faster, and easier to deploy. The site is composed on a web author's computer and compiled into static html pages that can be uploaded and easily served by a webserver like Apache or Nginx.

Individual posts and pages in Sculpin are composed in either Markdown, Twig, or HTML. Learning the Markdown syntax is straightforward and provides a really clean and simple way of writing web documents. Twig is a powerful and easy to use PHP templating engine with loads of great documentation.

Read More|Comments (0)

Hello, World!

March 1, 2014

I'm excited to be launching this site and to start blogging for the first time in many years. I expect most posts to be technical in nature, revolving around the technologies that I'm working with at the moment as a developer. I also keep bees and am growing a backyard garden and orchard, so there may be a post or two on those topics as well.

There is an rss link at the top of the page, so you should subscribe. Thanks for reading!

Read More|Comments (0)

< older posts

About This Site

This site was designed by We Are How.

This site is powered by Sculpin static site generator and the source is available here.

Yotta = 10^24, or 1 000 000 000 000 000 000 000 000, the largest metric prefix.


Get in touch to find out how we can help you refine your vision and implement a dynamite product that will help your business grow. Our agile product development process is thoughtfully designed to give clients ongoing feedback and visibility from project inception to completion.