# Linux - Rails - PostgreSQL partitioning

**URL:** <https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430>\
**Category:** Rails\
**Created:** [August 18, 2006, 4:21am UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430 "2006-08-18T04:21:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 18, 2006, 4:21am UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/1 "2006-08-18T04:21:50Z")

</div>

I am getting some larger hard drives and will migrate my intranet  
application onto the new hard drives. I am using CentOS 4. The current  
setup uses one small boot volume (ext2) and the rest is partitioned into  
one big LVM.

Does it make sense to partition /var/lib/pgsql separately? (thinking  
mostly in terms of performance)

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 18, 2006, 10:31am UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/2 "2006-08-18T10:31:55Z")

</div>

On 18/08/06, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am getting some larger hard drives and will migrate my intranet  
> application onto the new hard drives. I am using CentOS 4. The current  
> setup uses one small boot volume (ext2) and the rest is partitioned into  
> one big LVM.
> 
> Does it make sense to partition /var/lib/pgsql separately? (thinking  
> mostly in terms of performance)

If you’re using LVM, then probably not (you don’t have an easy way  
of telling where the extents are physically located on disk).

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 18, 2006, 3:08pm UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/3 "2006-08-18T15:08:26Z")

</div>

Dick D. wrote:

> of telling where the extents are physically located on disk).  
> short answer: yes, I would

explanation:

It may not give you a big performance difference, but it does separate  
the postgres files from the rest of the system.

If your main system drive does lots of updates, the fragmentation might  
slow things down. I don’t know the disk usage patterns of postgres, but  
I did have a separate partition for it and another app which did lots of  
updates and cause fragmentation.

using a separate partition also insulates postgres from other daemons in  
case the fill up the disk.

Jason E.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 18, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/4 "2006-08-18T17:35:49Z")

</div>

On Fri, 2006-08-18 at 09:06 -0400, Jason E. wrote:

> > If you’re using LVM, then probably not (you don’t have an easy way  
> > I did have a separate partition for it and another app which did lots of  
> > updates and cause fragmentation.
> 
> using a separate partition also insulates postgres from other daemons in  
> case the fill up the disk.

* * *

This server is only going to be used for the Rails intranet  
application.

Thus the only things of interest are going to be  
Apache/PostgreSQL/ruby-rails and I will install enough to run a KDE  
desktop when necessary.

I don’t think I will have any issues with fragmentation or rampant  
logging - at least thus far, the load level and disk usage has been tame  
but I do have a large section of code getting ready to be deployed which  
also means that the number of users simultaneously accessing the Rails  
application will jump up.

Even with 10-15 simultaneous users, I don’t expect there to be too many  
issues with performance but I am trying to anticipate the issues and  
disk partitioning is much harder to do after the fact which is why I  
asked before I make my final deployment choices.

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 19, 2006, 3:14pm UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/5 "2006-08-19T15:14:51Z")

</div>

Craig W. wrote:

> > > >
> > 
> > It may not give you a big performance difference, but it does separate
> 
> * * *
> 
> also means that the number of users simultaneously accessing the Rails  
> application will jump up.
> 
> Even with 10-15 simultaneous users, I don’t expect there to be too many  
> issues with performance but I am trying to anticipate the issues and  
> disk partitioning is much harder to do after the fact which is why I  
> asked before I make my final deployment choices.

If you have the option, leave say half or a quarter of your LVM volume  
group unallocated. Then you can create/grow volumes as needed.

Jason

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 19, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/6 "2006-08-19T17:35:00Z")

</div>

On Sat, 2006-08-19 at 10:03 -0400, Michael A. wrote:

> PG partitioning can also provide performance benefits if used  
> your LVM on top of RAID10, you be fine for most applications. At that  
> point, you just need to benchmark your app and see if you are IO  
> bound. If so, rinse and repeat.

* * *

I was thinking primarily about partitioning to help out with IO. I am  
only going to use RAID 1 and keep the 3rd drive as a hot spare since  
what I have noticed is that RAID 5 doesn’t enhance performance on Linux

- this is a Dell 1750 with a PERC 3/Di controller.

I **might** be able to partition some of the databases down the road  
thinking that I will be able to archive and remove some of the data over  
time but I haven’t written that part of the application yet… 😉

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [August 19, 2006, 4:04pm UTC](https://www.ruby-forum.com/t/linux-rails-postgresql-partitioning/65430/7 "2006-08-19T16:04:53Z")

</div>

> Does it make sense to partition /var/lib/pgsql separately? (thinking  
> mostly in terms of performance)

Really depends on your usage pattern and you app. Partitioning with  
PG is great when you can logically partition your data, like by month  
or by division or something along those lines. You can then easily  
manage each partition individually, and say, only backup the most  
current month or archive the earliest month to disk and drop the  
partition.

PG partitioning can also provide performance benefits if used  
correctly and you remember to turn on constraint\_exclusion. Then, you  
will hopefully only be searching/updating the tables that meet some  
sort of constraint criteria. So you need to see if you can easily  
logically partition your data and if you access patterns don’t usually  
cross too many partition boundaries. Oh, and pgpsql is a tremendous  
help in generating all the DDL that you might need.

It sounds like you might also be talking about using partitioning to  
help out with IO. This really works best if you take a little more  
care in setting up your disks. If you follow best practices and put  
your LVM on top of RAID10, you be fine for most applications. At that  
point, you just need to benchmark your app and see if you are IO  
bound. If so, rinse and repeat.
