MySQL Forums
Forum List  »  Optimizer & Parser

Re: BETWEEN a DATE and a hard place
Posted by: Gerald Bayles
Date: May 01, 2014 09:41AM

Thanks for all your help. I am partitioning by week of year, totaling 53, rather than the 100+ I was originally going to do. I am using RANGE partitions rather than KEY.

As a token of my appreciation, here's a little python program that generates evenly distributed RANGE PARTITION values (INT only). It is somewhat general purpose and saved me a visit to the doctor for carpal tunnel syndrome.

I'm sure it'll prove absolutely useless to you but it makes me feel better about being so difficult :).


import optparse


if __name__ == '__main__':
parser = optparse.OptionParser(usage='%prog [options]')
parser.set_defaults(minVal=1, maxVal=53, count=53)
parser.add_option('-i', '--min', dest='minVal', action='store', type='int', help='min value (default: %default)')
parser.add_option('-a', '--max', dest='maxVal', action='store', type='int', help='max value (default: %default)')
parser.add_option('-c', '--count', dest='count', action='store', type='int', help='partition count (default: %default)')

options, junk = parser.parse_args()

part = 0
incr = float (options.maxVal - options.minVal + 1) / float(options.count)
while part < options.count:
val = int((part+1)*incr) + options.minVal
print ("PARTITION p"+str(part)+" VALUES LESS THAN ("+str(val)+"),")
part+=1

Options: ReplyQuote


Subject
Views
Written By
Posted
2174
April 16, 2014 02:07PM
1152
April 18, 2014 05:19PM
1195
April 24, 2014 08:20PM
1155
April 26, 2014 05:46AM
Re: BETWEEN a DATE and a hard place
1259
May 01, 2014 09:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.