Good question, Marcus! Yeah, that's possible and that's how you would scale
and get better performance. So db1 might have Q=2 (that's the default) and
with N=3, it might pick shards on nodes 2, 15, 18, 41, 54, 93. So two
ranges and 3 copies for each range. But you can also db2 with Q=16 and N=3
and then Q*N=48 shards would be spread amongst other nodes randomly.

You can read more about it at
https://docs.couchdb.org/en/stable/cluster/theory.html

Cheers,
-Nick


On Wed, Jun 12, 2024 at 2:45 PM Markus Doppelbauer
<[email protected]> wrote:

> Dear Nick,
>
> Is it possible to set the number of shards (Q) lower than the number of
> nodes?
> Wouldn't that result in unused nodes?
>
> Best wishes!
> Marcus
>
>
> Am Mittwoch, dem 12.06.2024 um 13:54 -0400 schrieb Nick Vatamaniuc:
> > Another feature related to efficient view querying are
> > partitioneddatabases:
> > https://docs.couchdb.org/en/stable/partitioned-dbs/index.html.It's a
> > bit of a niche, as you'd need to have a good partition key, butaside
> > from that, it can speed up your queries as responses would be
> > comingfrom a single shard only instead of Q shards.
> >
> >
> > On Wed, Jun 12, 2024 at 1:30 PM Markus Doppelbauer<
> > [email protected]> wrote:
> > > Hi Nick,Thank you very much for your reply.This is exactly what we
> > > are lookingfor.There are so many DBs that store the secondary
> > > indexlocally(Cassandra, Aerospike, SyllaDB, ...)Thanks again for
> > > the answerMarcus
> > >
> > > Am Mittwoch, dem 12.06.2024 um 13:23 -0400 schrieb Nick Vatamaniuc:
> > > > Hi Marcus,The node handling the request only queries the nodes
> > > > with shardcopies ofthat database. In a 100 node cluster the
> > > > shards for thatparticulardatabase might be present on only 6
> > > > nodes, depending on theQ and Nsharding factors, so it will query
> > > > 6 out 100 nodes. Forinstance, for N=3and Q=2 sharding factors, it
> > > > will first send N*Q=6requests, and wait untilit gets at least one
> > > > response for each of theQ=2 shard ranges. Thishappens very
> > > > quickly. Then, for the duration ofthe response, it will
> > > > onlystream responses from those Q=2 workers.So, to summarize for
> > > > a Q=2database, it will be a streaming responsefrom 2 workers. For
> > > > Q=4, from 4workers, etc...Cheers,-Nick
> > > > On Wed, Jun 12, 2024 at 1:00 PM Markus Doppelbauer<
> > > > [email protected]> wrote:
> > > > > Hello,Is the CouchDB-view a "global" or "local" index?For
> > > > > example, if acluster has 100 nodes, would the query askfor a
> > > > > single node - or100
> > > > > nodes?/.../_view/posts?startkey="foobar"&endkey="foobaz"Best
> > > > > wishesMarcus
>

Reply via email to