Writing categorical columns to HDF5 takes >100x than writing the corresponding ints
#### Code Sample, a copy-pastable example if possible

```python
import numpy as np
import pandas as pd
from pandas.api.types import CategoricalDtype
from time import time
np.random.seed(1)

options = ('Off', 'Low', 'Not working', 'Working bad badly')
p = np.array([0.8, 0.15, 0.049, 0.001])
categorical_type = CategoricalDtype(categories=options, ordered=True)
chunksize = 5*60*24
def generate_df(float_cols, categorical_cols):
    columns = ['column_'+str(i) for i in range(float_cols+categorical_cols)]
    float_data = np.random.rand(chunksize, float_cols)
    categorical_data = np.random.choice(options, p=p, size=(chunksize, categorical_cols))
    data = np.hstack((float_data, categorical_data))
    df = pd.DataFrame(data, columns = columns)
    for i, column in enumerate(df.columns):
        if i < float_cols:
            df[column] = df[column].astype(np.float32)
        else:
            #df[column] = df[column].astype(categorical_type) # uncomment this line and comment the next one to use categorical dtypes
            df[column] = (df[column].astype(categorical_type).cat.codes)
    return df

keys_list = ('root/one', 'root/two', 'root/three')
cols_list = ((250, 100), (100, 50), (30, 150))
store = pd.HDFStore('store.h5')
num_chunks=3
for i in range(num_chunks):
    for key, cols in zip(keys_list, cols_list):
        df = generate_df(*cols)
        start = time()
        store.append(key, df, format='table', index=False, expectedrows=chunksize*num_chunks)
        print('iteration {} key {} took {} seconds'.format(i, key, time()-start))
start = time()        
[store.create_table_index(key) for key in keys_list]
print('Indexing time {}'.format(time()-start))
store.close()
```
Results when using categorical columns:
```sh
iteration 0 key root/one took 2.6918983459472656 seconds
iteration 0 key root/two took 1.096679449081421 seconds
iteration 0 key root/three took 4.071650266647339 seconds
iteration 1 key root/one took 26.869133234024048 seconds
iteration 1 key root/two took 3.041396379470825 seconds
iteration 1 key root/three took 30.375636339187622 seconds
iteration 2 key root/one took 16.374237060546875 seconds
iteration 2 key root/two took 4.1381542682647705 seconds
iteration 2 key root/three took 69.06171131134033 seconds
Indexing time 7.9363789558410645
```

Results when using respective integers (int8):
```
iteration 0 key root/one took 0.019600391387939453 seconds
iteration 0 key root/two took 0.014739513397216797 seconds
iteration 0 key root/three took 0.011326074600219727 seconds
iteration 1 key root/one took 0.017159223556518555 seconds
iteration 1 key root/two took 0.012496709823608398 seconds
iteration 1 key root/three took 0.008722543716430664 seconds
iteration 2 key root/one took 0.017138242721557617 seconds
iteration 2 key root/two took 0.012415885925292969 seconds
iteration 2 key root/three took 0.008598804473876953 seconds
Indexing time 0.035831451416015625
```
#### Problem description

Two things seem strange to me given the previous results:
* For the categorical examples why is the 1st iteration much faster (~10x faster) then the following iterations?
* Why is it so much slower to write categorical data than the corresponding integers?

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-29-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.3.2
pip: 9.0.3
setuptools: 39.0.1
Cython: 0.27.3
numpy: 1.14.2
scipy: 1.0.1
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.6.6
patsy: 0.5.0
dateutil: 2.7.2
pytz: 2018.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.2.2
openpyxl: 2.4.10
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.2.1
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>
