You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by Ashuthosh Bhat <te...@googlemail.com> on 2017/08/02 06:40:12 UTC

Reading Indexes created in a DB

Dear all,

I am trying to read indexes created on various tables in a DB.  Is this
feature available in metamodel.  I could not find the same.

Checked tabletypes as well there is no type as index.

Please suggest.

Thanks,
Ashu

Re: Reading Indexes created in a DB

Posted by Kasper Sørensen <i....@gmail.com>.
We do have a simple boolean right now: Column.isIndexed(). So if you're
just trying to find out what indexes are there, we have it covered.

But there have also been some requests to improve this information,  see
https://issues.apache.org/jira/browse/METAMODEL-16

2017-08-02 6:58 GMT-07:00 Dennis Du Krøger <
Dennis.DuKroger@humaninference.com>:

> I think it would make sense. At least in theory, we should be able to get
> that information from the JDBC metadata classes. However, not all drivers
> are equally nice at actually providing the data.
>
>
> Thinking of it, let's maybe wait with conclusions until Kasper (project
> lead) gets a chance to reply. He might know a way to extract that
> information with what we already have.
>
>
> Best regards,
>
> Dennis
>
> ________________________________
> From: Ashuthosh Bhat <te...@googlemail.com>
> Sent: 02 August 2017 15:48:57
> To: dev@metamodel.apache.org
> Subject: Re: Reading Indexes created in a DB
>
> Thanks for quick revert Dennis.
>
> Can code contribution towards retrieval/creation of indexes be considered?
>
> Thanks,
> Ashu
>
> On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
> Dennis.DuKroger@humaninference.com> wrote:
>
> > Hi Ashu,
> >
> > Most information from SQL databases can be gathered using the
> > INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> > you'll need to see if there are some something specific for each
> database.
> >
> > E.g. for SQL Server you can query sys.indexes to get a list of all
> > indexes. To get the tables the indexes belongs to, you need to join
> > sys.tables on the object ID
> >
> > I believe something similar is available for most databases. But it's of
> > course quite a bit more involved than just getting a list of indexes.
> >
> > Best regards,
> > Dennis
> >
> > ________________________________
> > From: Ashuthosh Bhat <te...@googlemail.com>
> > Sent: 02 August 2017 08:40:12
> > To: dev@metamodel.apache.org
> > Subject: Reading Indexes created in a DB
> >
> > Dear all,
> >
> > I am trying to read indexes created on various tables in a DB.  Is this
> > feature available in metamodel.  I could not find the same.
> >
> > Checked tabletypes as well there is no type as index.
> >
> > Please suggest.
> >
> > Thanks,
> > Ashu
> >
>

Re: Reading Indexes created in a DB

Posted by Kasper Sørensen <i....@gmail.com>.
What do you want my reply on? :-) I read it as you've solved your problem?
If you have a solution that you'd like to contribute to the project we're
always open for that sort of thing :-)

2017-08-03 11:17 GMT-07:00 Ashuthosh Bhat <te...@googlemail.com>:

> Dear Kasper,
>
> Waiting for your reply, just in case the mail trail skipped your radar.
>
> Thanks,
> Ashu
>
> On Aug 2, 2017 9:47 PM, "Ashuthosh Bhat" <te...@googlemail.com>
> wrote:
>
> > Sure, it would be nice to retrieve auto-increment column details as well
> > using metamodel.  I was using 4.5.4 couldnt find anything specific and
> > wrote little top up jdbc meta code to get those details on each table in
> > db.  Wrote code specific to MySQL though (limit), works for me as of now.
> >
> > Warm Regards,
> > Ashu
> >
> > On Aug 2, 2017 7:28 PM, "Dennis Du Krøger" <Dennis.DuKroger@
> > humaninference.com> wrote:
> >
> > I think it would make sense. At least in theory, we should be able to get
> > that information from the JDBC metadata classes. However, not all drivers
> > are equally nice at actually providing the data.
> >
> >
> > Thinking of it, let's maybe wait with conclusions until Kasper (project
> > lead) gets a chance to reply. He might know a way to extract that
> > information with what we already have.
> >
> >
> > Best regards,
> >
> > Dennis
> >
> > ________________________________
> > From: Ashuthosh Bhat <te...@googlemail.com>
> > Sent: 02 August 2017 15:48:57
> > To: dev@metamodel.apache.org
> > Subject: Re: Reading Indexes created in a DB
> >
> > Thanks for quick revert Dennis.
> >
> > Can code contribution towards retrieval/creation of indexes be
> considered?
> >
> > Thanks,
> > Ashu
> >
> > On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
> > Dennis.DuKroger@humaninference.com> wrote:
> >
> > > Hi Ashu,
> > >
> > > Most information from SQL databases can be gathered using the
> > > INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> > > you'll need to see if there are some something specific for each
> > database.
> > >
> > > E.g. for SQL Server you can query sys.indexes to get a list of all
> > > indexes. To get the tables the indexes belongs to, you need to join
> > > sys.tables on the object ID
> > >
> > > I believe something similar is available for most databases. But it's
> of
> > > course quite a bit more involved than just getting a list of indexes.
> > >
> > > Best regards,
> > > Dennis
> > >
> > > ________________________________
> > > From: Ashuthosh Bhat <te...@googlemail.com>
> > > Sent: 02 August 2017 08:40:12
> > > To: dev@metamodel.apache.org
> > > Subject: Reading Indexes created in a DB
> > >
> > > Dear all,
> > >
> > > I am trying to read indexes created on various tables in a DB.  Is this
> > > feature available in metamodel.  I could not find the same.
> > >
> > > Checked tabletypes as well there is no type as index.
> > >
> > > Please suggest.
> > >
> > > Thanks,
> > > Ashu
> > >
> >
> >
> >
>

Re: Reading Indexes created in a DB

Posted by Ashuthosh Bhat <te...@googlemail.com>.
Dear Kasper,

Waiting for your reply, just in case the mail trail skipped your radar.

Thanks,
Ashu

On Aug 2, 2017 9:47 PM, "Ashuthosh Bhat" <te...@googlemail.com>
wrote:

> Sure, it would be nice to retrieve auto-increment column details as well
> using metamodel.  I was using 4.5.4 couldnt find anything specific and
> wrote little top up jdbc meta code to get those details on each table in
> db.  Wrote code specific to MySQL though (limit), works for me as of now.
>
> Warm Regards,
> Ashu
>
> On Aug 2, 2017 7:28 PM, "Dennis Du Krøger" <Dennis.DuKroger@
> humaninference.com> wrote:
>
> I think it would make sense. At least in theory, we should be able to get
> that information from the JDBC metadata classes. However, not all drivers
> are equally nice at actually providing the data.
>
>
> Thinking of it, let's maybe wait with conclusions until Kasper (project
> lead) gets a chance to reply. He might know a way to extract that
> information with what we already have.
>
>
> Best regards,
>
> Dennis
>
> ________________________________
> From: Ashuthosh Bhat <te...@googlemail.com>
> Sent: 02 August 2017 15:48:57
> To: dev@metamodel.apache.org
> Subject: Re: Reading Indexes created in a DB
>
> Thanks for quick revert Dennis.
>
> Can code contribution towards retrieval/creation of indexes be considered?
>
> Thanks,
> Ashu
>
> On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
> Dennis.DuKroger@humaninference.com> wrote:
>
> > Hi Ashu,
> >
> > Most information from SQL databases can be gathered using the
> > INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> > you'll need to see if there are some something specific for each
> database.
> >
> > E.g. for SQL Server you can query sys.indexes to get a list of all
> > indexes. To get the tables the indexes belongs to, you need to join
> > sys.tables on the object ID
> >
> > I believe something similar is available for most databases. But it's of
> > course quite a bit more involved than just getting a list of indexes.
> >
> > Best regards,
> > Dennis
> >
> > ________________________________
> > From: Ashuthosh Bhat <te...@googlemail.com>
> > Sent: 02 August 2017 08:40:12
> > To: dev@metamodel.apache.org
> > Subject: Reading Indexes created in a DB
> >
> > Dear all,
> >
> > I am trying to read indexes created on various tables in a DB.  Is this
> > feature available in metamodel.  I could not find the same.
> >
> > Checked tabletypes as well there is no type as index.
> >
> > Please suggest.
> >
> > Thanks,
> > Ashu
> >
>
>
>

Re: Reading Indexes created in a DB

Posted by Ashuthosh Bhat <te...@googlemail.com>.
Sure, it would be nice to retrieve auto-increment column details as well
using metamodel.  I was using 4.5.4 couldnt find anything specific and
wrote little top up jdbc meta code to get those details on each table in
db.  Wrote code specific to MySQL though (limit), works for me as of now.

Warm Regards,
Ashu

On Aug 2, 2017 7:28 PM, "Dennis Du Krøger" <
Dennis.DuKroger@humaninference.com> wrote:

I think it would make sense. At least in theory, we should be able to get
that information from the JDBC metadata classes. However, not all drivers
are equally nice at actually providing the data.


Thinking of it, let's maybe wait with conclusions until Kasper (project
lead) gets a chance to reply. He might know a way to extract that
information with what we already have.


Best regards,

Dennis

________________________________
From: Ashuthosh Bhat <te...@googlemail.com>
Sent: 02 August 2017 15:48:57
To: dev@metamodel.apache.org
Subject: Re: Reading Indexes created in a DB

Thanks for quick revert Dennis.

Can code contribution towards retrieval/creation of indexes be considered?

Thanks,
Ashu

On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
Dennis.DuKroger@humaninference.com> wrote:

> Hi Ashu,
>
> Most information from SQL databases can be gathered using the
> INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> you'll need to see if there are some something specific for each database.
>
> E.g. for SQL Server you can query sys.indexes to get a list of all
> indexes. To get the tables the indexes belongs to, you need to join
> sys.tables on the object ID
>
> I believe something similar is available for most databases. But it's of
> course quite a bit more involved than just getting a list of indexes.
>
> Best regards,
> Dennis
>
> ________________________________
> From: Ashuthosh Bhat <te...@googlemail.com>
> Sent: 02 August 2017 08:40:12
> To: dev@metamodel.apache.org
> Subject: Reading Indexes created in a DB
>
> Dear all,
>
> I am trying to read indexes created on various tables in a DB.  Is this
> feature available in metamodel.  I could not find the same.
>
> Checked tabletypes as well there is no type as index.
>
> Please suggest.
>
> Thanks,
> Ashu
>

Re: Reading Indexes created in a DB

Posted by Dennis Du Krøger <De...@humaninference.com>.
I think it would make sense. At least in theory, we should be able to get that information from the JDBC metadata classes. However, not all drivers are equally nice at actually providing the data.


Thinking of it, let's maybe wait with conclusions until Kasper (project lead) gets a chance to reply. He might know a way to extract that information with what we already have.


Best regards,

Dennis

________________________________
From: Ashuthosh Bhat <te...@googlemail.com>
Sent: 02 August 2017 15:48:57
To: dev@metamodel.apache.org
Subject: Re: Reading Indexes created in a DB

Thanks for quick revert Dennis.

Can code contribution towards retrieval/creation of indexes be considered?

Thanks,
Ashu

On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
Dennis.DuKroger@humaninference.com> wrote:

> Hi Ashu,
>
> Most information from SQL databases can be gathered using the
> INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> you'll need to see if there are some something specific for each database.
>
> E.g. for SQL Server you can query sys.indexes to get a list of all
> indexes. To get the tables the indexes belongs to, you need to join
> sys.tables on the object ID
>
> I believe something similar is available for most databases. But it's of
> course quite a bit more involved than just getting a list of indexes.
>
> Best regards,
> Dennis
>
> ________________________________
> From: Ashuthosh Bhat <te...@googlemail.com>
> Sent: 02 August 2017 08:40:12
> To: dev@metamodel.apache.org
> Subject: Reading Indexes created in a DB
>
> Dear all,
>
> I am trying to read indexes created on various tables in a DB.  Is this
> feature available in metamodel.  I could not find the same.
>
> Checked tabletypes as well there is no type as index.
>
> Please suggest.
>
> Thanks,
> Ashu
>

Re: Reading Indexes created in a DB

Posted by Ashuthosh Bhat <te...@googlemail.com>.
Thanks for quick revert Dennis.

Can code contribution towards retrieval/creation of indexes be considered?

Thanks,
Ashu

On Wed, Aug 2, 2017 at 12:57 PM, Dennis Du Krøger <
Dennis.DuKroger@humaninference.com> wrote:

> Hi Ashu,
>
> Most information from SQL databases can be gathered using the
> INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so
> you'll need to see if there are some something specific for each database.
>
> E.g. for SQL Server you can query sys.indexes to get a list of all
> indexes. To get the tables the indexes belongs to, you need to join
> sys.tables on the object ID
>
> I believe something similar is available for most databases. But it's of
> course quite a bit more involved than just getting a list of indexes.
>
> Best regards,
> Dennis
>
> ________________________________
> From: Ashuthosh Bhat <te...@googlemail.com>
> Sent: 02 August 2017 08:40:12
> To: dev@metamodel.apache.org
> Subject: Reading Indexes created in a DB
>
> Dear all,
>
> I am trying to read indexes created on various tables in a DB.  Is this
> feature available in metamodel.  I could not find the same.
>
> Checked tabletypes as well there is no type as index.
>
> Please suggest.
>
> Thanks,
> Ashu
>

Re: Reading Indexes created in a DB

Posted by Dennis Du Krøger <De...@humaninference.com>.
Hi Ashu,

Most information from SQL databases can be gathered using the INFORMATION_SCHEMA schema. Unfortunately, indexes isn't one of them, so you'll need to see if there are some something specific for each database.

E.g. for SQL Server you can query sys.indexes to get a list of all indexes. To get the tables the indexes belongs to, you need to join sys.tables on the object ID

I believe something similar is available for most databases. But it's of course quite a bit more involved than just getting a list of indexes.

Best regards,
Dennis

________________________________
From: Ashuthosh Bhat <te...@googlemail.com>
Sent: 02 August 2017 08:40:12
To: dev@metamodel.apache.org
Subject: Reading Indexes created in a DB

Dear all,

I am trying to read indexes created on various tables in a DB.  Is this
feature available in metamodel.  I could not find the same.

Checked tabletypes as well there is no type as index.

Please suggest.

Thanks,
Ashu