# Building Segments Based on Contact ID

**URL:** https://forum.mautic.org/t/building-segments-based-on-contact-id/23872
**Category:** Product Support
**Created:** [April 25, 2022, 8:32am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872 "2022-04-25T08:32:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)
#### Post date: [April 25, 2022, 8:32am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/1 "2022-04-25T08:32:11Z")

</div>

Does anyone know if there is anyway to build a segment based on contact id.

We need to build certain size segments and would like to be able to build them with filters like contact\_id \> 1 and contact\_id \< 100.

I have checked out the SQL plugin, however from what I can see this only works inside a campaign.

Our main issue with using this is we are running a client with close to 1M contacts, so if we were to use this inside a number of campaigns this would still take a very long time to update each campaign and then to even trigger these events in each campaign

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [April 25, 2022, 8:49am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/2 "2022-04-25T08:49:10Z")

</div>

You want to create contact ID based segments because you want to run multi thread campaigns or paralell execute things?

---

<div class="post-metadata">

### Author: ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)
#### Post date: [April 25, 2022, 8:54am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/3 "2022-04-25T08:54:29Z")

</div>

if I understand my needs correctly parallel execute things.

My main issue to be more specific is we have a limitation of sending out around 10K SMS per hour, however if I split this into separate campaigns with separate sms messages, then I am able to send out 10K multiplied by the number of campaigns I have set up for that specific hour

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [April 25, 2022, 10:40am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/4 "2022-04-25T10:40:40Z")

</div>

I think you are better off multi-threading.

mautic:campaigns:trigger [options]

Options:  
-i, --campaign-id[=CAMPAIGN-ID]  
Trigger events for a specific campaign. Otherwise, all campaigns will be triggered.  
–campaign-limit[=CAMPAIGN-LIMIT]  
Limit number of contacts on a per campaign basis  
–contact-id[=CONTACT-ID]  
Trigger events for a specific contact.  
–contact-ids[=CONTACT-IDS]  
CSV of contact IDs to evaluate.  
–min-contact-id[=MIN-CONTACT-ID]  
Trigger events starting at a specific contact ID.  
–max-contact-id[=MAX-CONTACT-ID]  
Trigger events starting up to a specific contact ID.  
–thread-id[=THREAD-ID]  
The number of this current process if running multiple in parallel.  
–max-threads[=MAX-THREADS]  
The maximum number of processes you intend to run in parallel.  
–kickoff-only  
Just kickoff the campaign  
–scheduled-only  
Just execute scheduled events  
–inactive-only  
Just execute scheduled events  
-l, --batch-limit[=BATCH-LIMIT]  
Set batch size of contacts to process per round. Defaults to 100. [default: 100]  
-f, --force  
Force execution even if another process is assumed running.  
–bypass-locking  
Bypass locking.  
-t, --timeout=TIMEOUT

You can divide the ids into ranges and execute accordingly.  
I have a proof of concept of this already working, but haven’t got time to do a nicer version.  
It works similar to the smart segment script I wrote.

---

<div class="post-metadata">

### Author: ![pierre\_a](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pierre_a/32/7031_2.png) [@pierre\_a](https://forum.mautic.org/u/pierre_a)
#### Post date: [April 25, 2022, 4:29pm UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/5 "2022-04-25T16:29:16Z")

</div>

Hello @mikew,

> [@mikew](#):
>
> My main issue to be more specific is we have a limitation of sending out around 10K SMS per hour, however if I split this into separate campaigns with separate sms messages, then I am able to send out 10K multiplied by the number of campaigns I have set up for that specific hour

You can solve this point with what @joeyk proposes or you can see with your SMS provider to make this limit evolve 😉

For my part, I have a provider to whom I send the volume I need AND he will then smooth this volume over time. Everyone has a role to play.

Pierre

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [April 26, 2022, 4:54am UTC](https://forum.mautic.org/t/building-segments-based-on-contact-id/23872/6 "2022-04-26T04:54:46Z")

</div>

Hi, thank you formyour imput.  
This is not about the sms limits.  
Its about Mautic capability to process campaigns fast enough.  
If Mautic can process 2500 steps / min, then 1 mill contact takes 400 minutes = over 6,5 hours.  
But if you process in 6 threads by limiting each thread to a certain id range, then u can do it in over 1 hour.
